How to check if the connection to the bbdd is open or not



How to check if the connection to mysql database is open or not?



ConnectionState state = connection.State;
if (state == ConnectionState.Open)
return true;
return true;
side note:connection can be Broken, Connnecting, Executing, Fetching
please import namespace:,


Hi, first of all sorry for my bad english!

I have the next situation:

but I don’t find an option to check or to get "connection.State"
How can I do?

Thanks in advance


Hi ,
Its a method you can use if you import namespace from import tab as shown and use if condition to check the condition.


Yes, but in my case, I have 2 variables: “myConnection” (Type: DatabaseConnection) and "“myConnState” (type: ConnectionState).

I think I need to associate or link both variables, but I have no idea.

No doubt I’m doing something wrong but I do not realize that.