LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you return the column headings of a recordset after performing a query on a database?

Solved!
Go to solution

Hi everyone,

 

I am using LabVIEW 8.2.1 and the LabVIEW Database Connectivity Toolset to perform a query and get the result set.  I am able to obtain the data but not the column names from the specified query.

 

I want to return these queries in MS Excel reports and having the column names would be helpful without me having to create the headings myself.  Any ideas would be greatly appreciated.

0 Kudos
Message 1 of 10
(3,196 Views)

Use list columns under utilities then build array like this

 

getcoluns.png

=====================
LabVIEW 2012


0 Kudos
Message 2 of 10
(3,191 Views)

Wouldn't that be for a specific table in my database? My query consists of joining multiple tables and only selecting certain column headings.

Example:

 

SELECT M.SerialNumber, M.Date, G.Frequency FROM main M JOIN gain G ON G.Test_ID=M.Test_ID Where M.Station_ID = '37' AND G.Direction = 'Tx'

0 Kudos
Message 3 of 10
(3,184 Views)
Good point. I'll have to think about that one.
=====================
LabVIEW 2012


0 Kudos
Message 4 of 10
(3,180 Views)

@cschruder wrote:

Wouldn't that be for a specific table in my database? My query consists of joining multiple tables and only selecting certain column headings.

Example:

 

SELECT M.SerialNumber, M.Date, G.Frequency FROM main M JOIN gain G ON G.Test_ID=M.Test_ID Where M.Station_ID = '37' AND G.Direction = 'Tx'


I'm confused. Your column names are in your SELECT statement.

0 Kudos
Message 5 of 10
(3,176 Views)

Yes, they are but when I perform the query and get the recordset, only the data is stored. I would like to have the column headings as well without having to create an array with the headings manually for each of my queries. 

0 Kudos
Message 6 of 10
(3,167 Views)

The only way I can think of doing this (right now) is using two of the list column info VIs.

 

Edit:

 

If you use a parameterized query you can use the column info used to create that in your spreadsheet.

=====================
LabVIEW 2012


0 Kudos
Message 7 of 10
(3,162 Views)

Or write a VI to parse a select statement.

0 Kudos
Message 8 of 10
(3,155 Views)

Thanks Dennis and Steve.  I thought there would be an easier way to do it but I guess parsing will have to do.

0 Kudos
Message 9 of 10
(3,150 Views)
Solution
Accepted by topic author cschruder

There is an easier way. Here is the snippet, VI also attached in 8.2 format. I see you marked the solution but it is possible to change.

 

get columns and rows.png

=====================
LabVIEW 2012


Message 10 of 10
(3,145 Views)