Determine if a database connection is good

On my main form when my program opens I have some labels as flags to indicate if there is a good connection to a couple of PLC’s. I did this by creating tags to diagnostics/is connected in the gateway.

Am I able to grab the database status flag in the gateway somehow to indicate a good connection to the database?

Yes, those tags are located in the System folder under System > Gateway > Database > YourDatabaseName > Available.

Great! Thanks!

Those tags works for me if I stop and start the MySQL service.
Unfortunately they don’t if I drop the schema: in this case i still get a “valid” connection from the gateway and a connection “Available” from the tag.
In the Database Query Browser i still see the connection available with no table inside.
Running version 7.6.2

Am I missing anything?

The tag is most likely just validating that the database itself is there and not any particular tables within it.

You could try the following:

In the Gateway web page click Configure, then select Connections (under Databases) then find your connection in the list and click Edit.

Scroll down to the bottom and tick the checkbox “Show advanced properties”.

Within the Connection Testing section there should be a Validation Query entry that will probably
be just SELECT 1.

You could change this to SELECT column_name FROM table_name to check for the presence of a particular table.

Scroll down and Save Changes.

w.mandelli,

 I just tested this in 7.6.4-rc1 and it works fine using the method that Travis suggested. Unfortunately I don't have an installation of 7.6.2 to test with. But I was able to stop the MySQL service and the boolean for available cleared. Can you test this again?