IOW, is there a standard way of testing for this, a la:
if (! con.Open())
con.Open();
?
UPDATE: I guess I failed to mention that these are Oracle's ODP components I'm using. The OracleConnection component does not have a ConnectionState property.
Use the Connection.State property to check whether the connection is already open
if(con.State == ConnectionState.Closed){
con.Open();
}
if(Con.State != ConnectionState.Open)
con.Open();
if you want open only closed connections you can use
if(Con.State == ConnectionState.Close)
con.Open();
ConnectionState: http://msdn.microsoft.com/en-us/library/system.data.connectionstate.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With