I’m querying from C# application. I can do this:
MySqlConnection conn = new MySqlConnection(conString);
conn.Open();
//do database operation
Now how do I get the connection state of the conn object? What is strange is I get the intellisense dropdown showing the State property for MySqlConnection object and automatically leads me to ConnectionState enum from which I can choose. I could write the below code:
if (conn.State == ConnectionState.Open)
//print "Open"
But when I closely examined, I understood the ConnectionState enum is of type System.Data!! How do I get that automatically when I’m equating it with MySqlConnection object??
Also how do I get the connection state of MySQL connection like this:
if (conn.State == //equal to what?
MySqlConnectionis derived fromDBConnectionwhich is an abstract class that defines how all database connections should behave (that derive fromDBConnection). Thus will all these connections exposeConnectionStatewhich is in theSystem.Data.Commonnamespace. So this is valid: