Example Code

Get Column Headers from SQL Query with the Database Connectivity Toolkit

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW Database Connectivity Toolkit
  • LabVIEW

Code and Documents

Attachment

Overview

This example demonstrates how to query the column headers together with the content of the columns from a database.

 

Description

The Database Connectivity Toolkit offers multiple ways to query the content of a database table. You can use the DB Tools Select Data VI or the DB Tools Execute Query VI to get the content of a database table.

Both functions return the content of the table, but not the name of the corresponding columns. It is possible to get the column names with a SQL Query, but this query is different for each Database Management System (DBMS).

This example will push a test table named TestTable with some test data into LabVIEW.mdb. The Rec GetData VI (<labview>\addons\database\Recordset.llb\Rec GetData.vi) is used afterwards to get a reference to the recordset which offers a name property which provides the column names.

 

Requirements

 Software

  • LabVIEW Base Development System 2012 (or compatible)
  • Database Connectivity Toolkit 2012 (or compatible)

 Hardware

  • No hardware is necessary to use this example VI

 

Steps to Implement or Execute Code

  1. Download and open the attached ZIP-file
  2. Open and run the Query Column Header Names VI

 

Additional Information or References

Query Column Header Names - Front Panel.png

 

Query Column Header Names - Block Diagram.png 

Note: You cannot use this example on RT targets. The Database Connectivity Toolkit uses ActiveX to access the database. ActiveX is a Windows only technology and not available on RT targets.

 

**The code for this example has been edited to meet the new Community Example Style Guidelines. The edited copy is marked with the text ‘NIVerified’. Read here for more information about the new Example Guidelines and Community Platform.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
sushu
Member
Member
on

thank you very much ,so by your code i got the way to get the columns of the table.thanks very much.

搜狗截图20140901144558.png

sushu;
Certified LabVIEW Developer (CLD);