06-22-2006 03:44 PM
06-22-2006 04:27 PM
Now, I haven't worked with ADO connections in LabVIEW, but I have in other languages, and it was usually a good idea to open the DB connection, get all the info you want (fill up the recordsets based on the different queries), and close it, so that it doesn't hold many resources hostage for too long. For example, using ASP, it was bad practice to store the actual DB connection object in the global.asa file. Instead, I would open connection, get recordset, close connection and clear recordset for each page that had dynamic data.
I don't know whether this would work for your program though. Could you perhaps have one VI that does this communication with the DB, and then passes out the data to the other VIs? Just a thought.
06-22-2006 04:36 PM
06-22-2006 05:04 PM
06-23-2006 01:35 AM
It works for me, but only if there is always a VI either running or reserved for running holding the reference. Once all the VIs holding the reference go idle it seems that LV automatically clears the reference and it becomes invalid.
What you can try doing instead is using an LV2 style global which will have several states - at first it receives the connection information and remembers it. Then, whenever you request a connection, it runs one of the DB VIs to see that the connection is valid and if it isn't, it calls the Open Connection state again (since it remembers the connection information). In the end, that VI returns either a valid connection or an error which you can use.