From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

DCT parameterized query - strange behavior

Solved!
Go to solution

I'm using the database connectivity toolkit to build a parameterized query, but it's not working as expected. I have four parameters, one of which is set by an array of values. When each array value is passed singly (1 element array), the query works. When passing two values, the order determines if both record sets are returned. I.e. passing "Temperature" before "Humidity" returns both of the expected recordsets, but reversing the order causes the second set to return empty. Has anyone else seen this kind of behavior before?

 

I'm not sure how to do a parameterized query from SQL Server Management Studio, but that's next on my list of troubleshooting.

 

Details:

LabVIEW Full 2011 SP1 (11.0.1f2)

DCT (11.0.0)

SQL Server Express 2012

0 Kudos
Message 1 of 8
(3,225 Views)

Your parameters array is empty.  It must have the same number of parameters as your query.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 8
(3,211 Views)

It's definitely populated in my copy, otherwise it would throw an error for any/all of the set parameter.vi calls. When this behavior happens, no errors are thrown and the query seems to execute successfully.

0 Kudos
Message 3 of 8
(3,207 Views)

True.  I see nothing that would cause this behavior. 

 

Your recordset data 2 control is a 3 dimensional array.  are you sure that you aren't viewing the wrong indexes?

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 4 of 8
(3,204 Views)

I've got a probe on the variant array output of the Fetch Recordset to check the raw output. The 3 dimensional array shows the correct data when both sets return correctly, but that's not where I'm monitoring the results.

 

I'm still trying to find some info on executing a parameterized query in Management Studio, but there doesn't seem to be much in terms of example code.

0 Kudos
Message 5 of 8
(3,197 Views)
Solution
Accepted by topic author Cranky

This should get you really close.  Just wire your inputs into the right parameter and create the stored procedure in your database.

DCT oddity_BD.png

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 6 of 8
(3,193 Views)

Interesting. I'm still pretty new to SQL, so I hadn't thought of stored procedures yet. I'll give that a whack and see how it works.

 

Thanks for your feedback!

0 Kudos
Message 7 of 8
(3,189 Views)

Looks like a stored procedure is the way to go. The only snag I hit was the missing "END" in  your SQL text.

 

This doesn't fix the root cause, but does provide a workaround, so I'll mark it as the solution. Thanks again!

0 Kudos
Message 8 of 8
(3,137 Views)