LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get a numeric reference to an ODBC connection to check if I already have a database connection ?

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 ?
0 Kudos
Message 1 of 4
(3,162 Views)
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.
0 Kudos
Message 2 of 4
(3,162 Views)
Thanks - I would have looked for some time before I came across this VI.
0 Kudos
Message 3 of 4
(3,162 Views)
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.
0 Kudos
Message 4 of 4
(3,161 Views)