Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
[WebMethod]
public static string[] GetRecord(string pid)
{

//how to connect database

}


Problem : GetRecord is static method so how we create instanse of sqlconnection
Posted
Comments
[no name] 1-Jun-13 11:43am    
SqlConnection con = new SqlConnection(your connection string)
Member 8233601 1-Jun-13 12:09pm    
can we create instance in static method?????
CHill60 1-Jun-13 14:12pm    
Yes - why not? static just means that you don't have to have an instance of the object to use the method. http://msdn.microsoft.com/en-us/library/79b3xss3(v=vs.80).aspx[^]
Member 8233601 3-Jun-13 2:04am    
thnx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900