How to check whether Connection is Open or not?

 Posted by vishalneeraj-24503 on 12/20/2013 | Category: ADO.NET Interview questions | Views: 1013 | Points: 40
Answer:

With the help of State property of SqlConnection object,we can check whether Connection is Open or Close.
It has ConnectionState as Enum which has Open value.

For Example:-
if (con.State == ConnectionState.Open)

con.Close();


Here con is our SqlConnection object.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response