Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
This Document is not yet Rated  Rate this Document

How do I Convert Database Data to a Cluster?

Primary Software: LabVIEW Toolkits>>Database Connectivity Toolset
Primary Software Version: 1.0.1
Primary Software Fixed Version: N/A
Secondary Software: N/A

Problem:
I am using the Database Connectivity Toolset to access my database.  I am reading a table using Active Data Objects (ADO) to access the record set.  The table has multiple columns of data, and each has a different data-type.  How do I read the data into LabVIEW so that I have a cluster that matches the data-types of each column in the table?

Solution:
There is no direct way to do this.  When you access and query your database, you need to use the Database Variant to Data VI on the functions palette under Database Connectivity Toolset, to process the data.

This function has two required inputs.  The data returned from the database and the Type input.   The Type input only accepts the basic data-types (string, numerics, boolean etc.).  Create an array of strings constant and wire this to the Type input of the VI.

If your table had 30 different columns, you will get an array 1x30 of the string data type.  Then you can use the Array to Cluster VI to convert it into a cluster.

Arrays in LabVIEW can be dynamically sized and clusters cannot.  This means that the size of the cluster must be specified defined before run-time.  The default size is 9 elements (indexed from 0).

To change this, right click on the Array to Cluster function and go to Cluster Size which is at the bottom of the menu.  This will allow you to specify the size of the cluster (in this case 30).  The maximum size that a cluster can be is 256 elements.

Finally, process the cluster element by element and use the String/Number Conversion palette to convert the necessary strings into numbers so that you now have a cluster that matches the data-types for each element in your table.

Related Links:
KnowledgeBase 3MQ6LIDW: LabVIEW Database Connectivity Toolset Readme File

Attachments:





Report Date: 04/23/2008
Last Updated: 05/06/2008
Document ID: 4KMA5I2Z

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit