LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Database Toolkit: Reading data from SQL database

Hello,
 
I have been working on a automated test system storing data into a SQL server database.  Once you get your head wrapped around the toolkit and walk through some of the examples it is not too bad.  Writing to the database was very straight forward.  I simply put all of my data including the primary keys into a cluster and inserted the cluster into the specified table.  As I learned the hard way,  it is very important for all of your types to match up.  I saved double type from labview as decimal type in the SQL database, and long integer in labview as integer in the SQL database. 
 
For the the read VI, this is where my questions lie. After establishing a connection reference I used the "DB Tools Create Parameterized Query" VI combined with a SQL statement to find the recordset that I was looking for.  I used a standard SQL statement using the primary keys such as, "Select * From TableName Where Measurements = "%Measurements%" ".  This VI creates a command reference which I then passed to multiple "DB Tools Get Parameter Value" VIs.  I could not get this to work with the command reference. 
 
I then switched over to the "DB Tools Execute Query" inputting the same SQL statement I had used before.  THis VI passed a recordset reference, which I then passed to a "DB Tools Get Properties" VI to check if the database was empty or not.  I then passed the recordset reference to multiple "DB Tools Fetch Element Data"  VI's to read the data from the SQL database.  THis worked very well. 
 
therefore I am wondering:
What is the difference between a command reference and a recordset reference in the Database connectivity toolkit? 
Why would one work and not the other? 
Is there ever a case when you would want to use one method over the other? 
I have asked my app guys and Labview training instructor different database type questions, and I not received a decent answer to date.
 
Thanks,
 
Jackson
0 Kudos
Message 1 of 3
(4,031 Views)
Hello,
 
Can you pass the command reference to a single "DB Tools Get Parameter Value" VI?  What exactly do you mean when you say you couldn't get this to work with command references... can you post an error message or the results?  The documented difference is that they are different flavors of ADOs (activeX data objects), one is a command and the other is a recordset reference.  I know this does not draw a precise distinction, but I'd like to understand this problem fully so we can find one!
 
Please repost with anything more you can give!
 
Best Regards,
 
JLS
Best,
JLS
Sixclear
0 Kudos
Message 2 of 3
(4,013 Views)
check out msdn.microsoft.com for documentation on ado.  you can browse around the whole structure to see how it all works.   Also, look for visual basic examples to see how it is used.   Its been a while since I've used the database connection toolkit.  after having a bunch of trouble with it I decided to learn ado and dig into using activeX directly - its not so bad and its quite stable and fast.  .net is nice if you have a driver for your database - no variants.  msdn has good documentation on that too.

Message 3 of 3
(4,002 Views)