Here you are calling a non-static method "GetTheSqlStatement" from a static method "Main". That's where the problem lies.
Static methods are associated with a CLASS. All objects of that class shares the same static method. Static methods can be called without creating an instance, or,object of a class. But non-static methods are associated with an object of a class, which means, if you create an object of a class, then the non-static methods of that class are created. Otherwise, those methods aren't created at all.
In your code, you are calling a non-static method from a static method, but the non-static method does not exist, because you didn't create an instance of that class.
To solve the problem, make the "GetTheSqlStatement" method static. Or, create another class, where the "GetTheSqlStatement" method is a non-static member method. Then, create an instance of that class in "Main" and call the "GetTheSqlStatement" method like this :
static int Main()
{
MyClass myClass = new MyClass();
sqlSelectAdvDetails = myClass.GetTheSqlStatement();
}
Your class declaration should look something like this :
public class MyClass{
......................................
public string GetTheSqlStatement()
{
.......................
}
}
In the above code, you are using an object reference inside the "Main" static method, using which you are accessing the non-static member method "GetTheSqlStatement" method of that object.
I hope that helps you..................
Good Luck...............