if (con1.State == ConnectionState.Closed)
{
con1.Open();
}
Personally I think better design is called for here. You should know at any point in your code whether a connection is open. The problem is that you are proably passing around the same connection to various methods and at some point you can't be sure what state it is in, right? Streamline you code so that the state is obvious, this will help with maintainablility and flexibility down the road.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.