now i want to call another server side method from that static method..
public static string getData(string _mobileno)
if (_mobileno == null || _mobileno.Length == 0)
OleDbConnection conn = null;
string cnstring = ConfigurationSettings.AppSettings["ConnectionString"];
conn = new OleDbConnection(cnstring);
string _strQry = "Select distinct VISITOR_NAME from VISITOR_REG where MOBILE_NO=" + _mobileno+"";
OleDbCommand cmd = new OleDbCommand(_strQry, conn);
cmd.CommandType = CommandType.Text;
string name = Convert.ToString(cmd.ExecuteScalar());
when i call this setvalue..it gives me error
An object reference is required for the non-static field, method, or property
help me solve this...
Edited 5-Apr-11 22:04pm
Which class contains that method? Can you post the method definition for it? You need to access that method using that class object.
The SetValue method would need to be declared static, or you need to create an instance of the class that the SetValue method belongs to, and call the method from the instance. In this case I think declaring SetValue as static would be the way to go.
Hope this helps
You cannot continue development until you learn what a type is and what is the instance. This is your problem.—SA
Methods (non-static) methods work with instances. A static methods does not have a reference to an instance (passed implicitly as "this" to all instance methods), so the syntax of the call uses the name of the type. As a result, static methods cannot use instance methods (there is no known instance to pass). Same thing is with the properties (they are also methods, through accessors. A hint: the syntax for instance method call is:
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)