LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

having trouble with database variant to data

Solved!
Go to solution

Here is a VI that i am trying to put together. I am trying to connect to a remote SQL database and run queries. I can connect retreive the data, but i cannot use the database variant to data. I am really green with this whole procces.

 

Please help,

0 Kudos
Message 1 of 11
(3,756 Views)
Solution
Accepted by topic author TRAVO

The output of the Fetch All function is a 2D array of Variant.  The Variant to Data function only takes in a single value.  Put the function inside 2 nested loops to convert each element in the 2D array to a data type.  Rebuild the array by enabling indexing on the exiting of the loops.

 

VariantData.png

- tbob

Inventor of the WORM Global
Message 2 of 11
(3,752 Views)

Look at the shipping examples, specifically:

examples\database\Read All Data.vi

The examples are found by selecting Help-> Find Examples... and entering a keyword of 'database'.

 

 

If all you want to do is display the contents of a table, there is a function used in the vi above called

vi.lib\addons\database\Auxilliary.llb\DB Tools Select All Data.vi

that returns a 2D array of strings. This specific VI is not in the palettes and must be copied from the example or placed by using  Select a VI... from the top of the palettes menu.

Message Edited by Phillip Brooks on 04-06-2010 02:20 PM
0 Kudos
Message 3 of 11
(3,742 Views)

I am actually trying to connect, query and then use the query as an array for other VI's.

 

 

0 Kudos
Message 4 of 11
(3,734 Views)

TRAVO,

 

There is a new feature in Database Connectivity Toolkit in 2010 that can convert that array into specified data type you want directly. You can try it in LabVIEW platform 2010 beta.

Message Edited by Neil Li on 04-07-2010 09:49 AM
0 Kudos
Message 5 of 11
(3,704 Views)

I have 8.5.1 will this matter? Also, it would be nice if I could see the master with all the other database's and tables, and maybe keep a session open for queries rather than having to re-open the connection.

 

I appreciate the help 

0 Kudos
Message 6 of 11
(3,700 Views)
Sorry, Database Connectivity Toolkit 2010 can only be installed against LabVIEW 2010, so you can't use it with LV 8.5.1. I don't understand your second question very well. Do you mean after opening a connection you want to switch to another database which isn't specified as the master in the connection string. Which DBMS are you using? Can you paste your connection string for reference?
Message Edited by Neil Li on 04-07-2010 10:12 AM
0 Kudos
Message 7 of 11
(3,697 Views)

Neil Li wrote:

TRAVO,

 

There is a new feature in Database Connectivity Toolkit in 2010 that can convert that array into specified data type you want directly. You can try it in LabVIEW platform 2010 beta.

Message Edited by Neil Li on 04-07-2010 09:49 AM

Please re-read the beta agreement. You are not allowed to discuss features of LabVIEW 2010 or anything else associated with the beta in a public forum. 

0 Kudos
Message 8 of 11
(3,691 Views)
Sorry about that, I didn't notice that. You can remove my post then if it's possible.
0 Kudos
Message 9 of 11
(3,689 Views)

Sorry for being unclear, basically we have a central server that gets replication from many other servers. I would like to open the connection and keep it open. I think right now it opens connection, runs query,then closes connection. Now, i can use other interface tools (i.e. Toad SQLserver) to run multiple queries, but the amount of data that i am trying to pull and then run analysis on is too much for most applications. I can crunch through 1 years worth of 10min datapoints in about 8 seconds, so it just seems logical to hook the two together to cut out the middle guy. 

 

I also work in a monitoring center, I would like to use the continuous connection and data replication (continuous updating of data) to create a more intelligent monitoring system (big picture and far out of my reach right now ha). I would like to make a data crawler in some sense with triggers. 

0 Kudos
Message 10 of 11
(3,686 Views)