I am transitioning from the SQL toolset to the Database Connectivity Tool. Previously, when I openned a connection to an ODBC source the routine returned a numeric reference to the connection. I often save that reference and use it in subsequent calls to see if a connection is already open . How do I do the same with the Data Base Connection tool which returns a data type that is of type Connection ?
If you dig into the vi.lib\addons\database\connection.llb, there is a VI called "Conn Get Properties.vi". You might be able to use this VI to check the status of a connection. If a connection is already open, this VI will return the connection string, database, and provider. If the connection is not valid, it returns nothing and an error 1. You can also use the "Conn GetData.vi" which returns a cluster of data including the ADODB._Connection ActiveX refnum. This will also return an error if the connection reference is not valid.
You don't have to dig as much as described here because the VI is in the Functions palette. Go to the Database>>Utility subpalette. The last icon in the top row is the DB Tools Get Properties VI. This is a polymorphic VI that gives you information based on what kind of reference you wire to it. If you wire a Connection reference to the input, it uses the Conn Get Properties.vi mentioned above.