LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Detecting exisiting connection to a database

I've got a program that runs continuously that analyzes some signals.  On a rare occasion, the user will see some interesting signals, and I want to give the user a toggle button to turn on/off logging of the signal to a SQL database without stopping the Labview program.  Plus, I want Labview to re-connect automatically to the database should the database server need rebooted. The problem is detecting whether a database connection exists every time I run through the datacapture/datalog sequence BEFORE I attempt a database insert. I called tech support, and they said the only way to do this was to attempt a database insert, and if I get an error, then try to create a connection. While that method does work, its not what I'd call a good solution (I like errors to be true exceptions to be handled, not just standard operating methods).
 
My original attempt is coded in "db connection exists test.vi". This code does NOT properly detect the existence of a database connection and continues to establish a new connection every loop. This is proven by watching current processes in SQL and seeing them blow sky high when I run the vi.
 
The NI tech solution is coded in "db connection error test.vi".  This code does work,  but I am trying to get its functionality with better programming methods.
 
Both examples log to a database server called "devbox", database called "test", username "test", password "test", table "test", containing a single varchar column called "col1".
As I add other database functionality, this "error test" method is gonna become really clunky. Does anybody have any ideas on how to do this properly with the enterprise connectivity toolset or other methods?
 
Thanks in advance,
 
Jason

Message Edited by JSat on 10-21-2005 09:39 AM

Download All
0 Kudos
Message 1 of 5
(3,095 Views)

Jason,

I believe that there has been a previous thread about a very similar issue:

http://forums.ni.com/ni/board/message?board.id=170&message.id=148193

This link talks about using a the DB Tools Get Properties VI (Functions >> Database >> Utilities) to test for a connection.  If the reference for the connection is passed to this VI it will return some properties about the database if there is an active connection.  If there is no connection then it will error out and give error 1.  The help file for this VI will have a lot more information about this VI if you need it.  This is similar to the approach that you have implemented previously, but is a way to test the connection before actually calling the Insert VI.  Please don't hesitate to post with any further questions!

Andy F.  

-----------------------------------------------------------------
National Instruments
0 Kudos
Message 2 of 5
(3,067 Views)
Thanks! I tried it, and it worked great!
0 Kudos
Message 3 of 5
(3,045 Views)
Umm the link that is listed takes you back to this posting?
Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 4 of 5
(3,040 Views)
Yeah... no good excuse on that one.

http://forums.ni.com/ni/board/message?board.id=170&message.id=23270&requireLogin=False


-----------------------------------------------------------------
National Instruments
0 Kudos
Message 5 of 5
(3,023 Views)