From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SQL Fetch Fails to Retrieve Recordset

Solved!
Go to solution

I wrote some simple code in an attempt to query a MS SQL database and return a recordset. The query is actually a call to a stored procedure with the serial number of a top level assembly. The recordset returned should be a list of the sub-assembly part numbers in that top level assembly and their serial numbers. When I run the attached VI I do not get any data in the recordset although I have confirmed using Wireshark that the query was successfully executed and the expected subassembly data is indeed returned from the SQL server. Is there something wrong in my VI? Note that I coded the same sequence in Teststand using the built in database step types and I get the same result - Wireshark shows the successful query response data but Teststand can't seem to "find" it. Thanks for any help!

0 Kudos
Message 1 of 6
(2,589 Views)

Are you sure you are not getting the data? You need to convert the data from the variant data to strings. You may have data there that is showing up as unprintable characters in the variant data. We use the following to convert the data to strings.

 

Database variant to strings.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 6
(2,574 Views)

Thanks for the reply. I tried your suggestion but the data data found result is false and no records display in the recordset out indicator. I am not sure - maybe this is a firewall issue. I can see the data with Wireshark so I know it is being returned but maybe the firewall is blocking it from the Labview app. In any case I do not get any errors from Labview - everything runs as expected except that no data shows up. If I run the same query from the same physical machine using SQL Server Management Studio the data does show up in that app. Unfortunately I do not have control over the firewall on this machine to turn it off and try it.

0 Kudos
Message 3 of 6
(2,548 Views)

FYI, I was able to run this on a machine with the firewall disabled. That also did not work - same behavior. 

0 Kudos
Message 4 of 6
(2,544 Views)

That is very odd. I have not encountered that issue. We have been using the DB Toolkit extensively and have not seen this behavior.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 6
(2,542 Views)
Solution
Accepted by topic author orange68

FYI the solution to my problem was adding "SET NOCOUNT ON" and "SET ANSI_WARNINGS OFF" to the stored procedure script as mentioned here - https://stackoverflow.com/questions/16529032/operation-is-not-allowed-when-the-object-is-closed-when...

 

Oddly enough, my implementation in LabView did not produce this error but both TestStand and LabWindows did which is what led me to find the solution.

0 Kudos
Message 6 of 6
(2,532 Views)