LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ADO.Net - Why is the recordset closed when executing this SQL query?

Solved!
Go to solution

closed recordset.png

 

I'm running an SQL query using the Database Connectivity VI's. Nothing's modified on their block diagrams.

 

I noticed that when this query executes, it updates the DB just like you might expect, but when I try and obtain the result of the final SELECT, diving into the fetch_all VI, I see that the recordset which was created during the query execution VI is closed, so no data is returned. The cursor type on the sql query execution VI is normally just left as the default (forward-only), but I noticed that there was a new recordset creation when using a different cursor type, and thought this could be the root of my problem.

0 Kudos
Message 1 of 4
(3,733 Views)
Solution
Accepted by topic author ijustlovemath

I ended up figuring it out! I posted this on the LabVIEW subreddit, and it turns out the database connectivity VIs aren't very good with batch queries. I switched over to using methods and properties of the OdbcConnection, OdbcCommand, and OdbcDatareader classes to achieve what I wanted. Here's the code if you're interested:

0 Kudos
Message 2 of 4
(3,687 Views)

So where do you close the recordset in your solution? 

Where do you close the connection reference? 

 

You need to handle these references, to make sure that for once you don't have too many connections open to the database and that the memory is released. 

0 Kudos
Message 3 of 4
(3,675 Views)

That's handled elsewhere in the application. The open connection reference is held on to (not exactly as seen in the picture), as the application continously runs until it reachs some stop condition.

0 Kudos
Message 4 of 4
(3,671 Views)