I built a console application and I\'m trying to test if my application works as expected.
I create an instance of the API class as shown in the code below but I receive an
If you want to use an Object and not have all the members be static you need to reference the non-static member variables using an instance of the class.
Change:
Test_api.getQualWeight(ConStr, bin_Num, lblResults);
To:
Test_api.getQualWeight(Test_api.ConStr, Test_api.bin_Num, Test_api.lblResults);
Because ConStr, bin_Num, and lblResults are instance variables they must be references with an instance of the class - in this case Test_api.
Alternately, you could move those values into a global, static, scope by changing their declarations from:
String ConStr = "SERVER=myservername; Database=mydb; UID=mylogin; PWD=mypassword;encrypt=no;enlist=false";
String bin_Num = "201284-11-000";
Label lblResults;
To this:
static String ConStr = "SERVER=myservername; Database=mydb; UID=mylogin; PWD=mypassword;encrypt=no;enlist=false";
static String bin_Num = "201284-11-000";
static Label lblResults;