LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

single ADO refrence for multiple VIs??

Hello all,
 
I would like to know how efficient is the following method??
Using 'db tools open connection.vi', I am trying to get a reference in a VI by opening the db connection and use that reference in all other VIs as well. To transfer the refrence to all other VIs, I will create a global variable of type 'connection refernce' in the main VI(the one that opens the db connection) and same global variable(in read mode) in all other VIs. The thing I need to remember is that I must stop the main VI only afetr all other VIs to make a smooth db close. If I try to stop the main VI before all, then it is going to close the reference and all others won't be having any ref in their global variables that they are reading from.
 
Other than the main VI, none of the other VIs are neither opening, nor closing the db connections.Smiley Tongue
 
I have smulated the above and worked well, as long as I close the main VI after all others!
 
This is all to reduce the number of ODBC connections to oracle database.
 
So normally, if I have 10 VIs, I will have 10 ODBC connectons,
but here,
I might end up with only one connection that may minimise the stress on the oracle db.
 
Thaks for your comments.
0 Kudos
Message 1 of 2
(2,248 Views)

I don't know how "efficient" it is, but it certainly works.

A better variation is encapsulating the reference getting mechanism. For example, I use an action engine for obtaining the reference in all the VIs. When it is asked for the reference, it first checks to see that the reference actually works and if it doesn't, it goes automatically to its Open action and attempts to reopen the connection a couple of times using the settings it was originally given. The advantage here is that if the connection is lost, it will be renewed automatically, as well as hiding all the DB interaction inside the DB VIs.


___________________
Try to take over the world!
0 Kudos
Message 2 of 2
(2,235 Views)