LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SQL Fetch Recordset Data provides incomplete results

Solved!
Go to solution

I am using the code below to return data from an SQL database. However, all of the elements in the variant array are blank except for the last column. Using "Database Variant to Data" doesn't help (everything but the last column is still blank). All of the columns are being correctly sent from "List Columns" to "Select Data". The SQL query is a simple "Select" statement that should return all of the data in the table. The SQL table is set up with all fields as text. Yes, there is data in the table. What else could be wrong?

 

 SQL Issue.JPG

 

I am using LabVIEW 2009 and the database connectivity toolkit and MS SQL Server 2005 Management Studio Express.

0 Kudos
Message 1 of 19
(5,871 Views)
You can try just leaving the "Columns" input to the "Select Data" VI unwired.  It should return all columns then.  This will determine if there is something about the columns input that it doesn't like.  You should be getting a 2D array of variants.  Make sure that you check for your results in both dimensions.  "Database Variant to Data" does not work on arrays.  You must put it in For Loop to get your elements to convert properly.
0 Kudos
Message 2 of 19
(5,852 Views)
Thanks, I tried both of those things and still no luck. I get the same results with the columns terminal unwired. The variant array itself is blank except for on the last column index which has the correct data. Any other ideas?
Message Edited by Willy2a on 12-18-2009 09:41 AM
0 Kudos
Message 3 of 19
(5,845 Views)
Are you saying that the last column is in the correct index, but that there is nothing else being returned?
0 Kudos
Message 4 of 19
(5,840 Views)

The variant array looks like this:

 

variant array.JPG

 

There are the correct number of rows and columns, but only the last column has data.

0 Kudos
Message 5 of 19
(5,837 Views)
I am not sure what is wrong, and I never use those functions to do a query.  Are you just trying to get all data in the table?  If you are then do a standard query of "SELECT * FROM tablename".
0 Kudos
Message 6 of 19
(5,830 Views)

I get the same result with the code below. Any other ideas? Some kind of incompatability between LabVIEW and this version of SQL Server? I need to get this working by early next week.

 

code pic.JPG

0 Kudos
Message 7 of 19
(5,813 Views)
I've always had to put a ";" at the end of my queries.  I don't have Labview on this computer to look at my queries, but I can check tonight. 
0 Kudos
Message 8 of 19
(5,806 Views)
Hmmm. That didn't help either.
0 Kudos
Message 9 of 19
(5,802 Views)
And have you repeated the query in SQL Server itself? If you don't have a copy of the full SQL Server, you can download a free copy of SQL Server Express from Microsoft. You could also link to a SQL Server database in Access and run a query from there. I don't use the NI toolkit but I always run new queries from SQL Server Express first.
0 Kudos
Message 10 of 19
(5,796 Views)