LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot get column names from LabVIEW SQL statement

Has anyone worked with LabVIEW SQL from Hans-Petter Halvorsen. I have used it to get column names from a table. So I used the SQL query 

SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Kokam_List' ORDER BY ORDINAL_POSITION;

and give it to the SQL select function and run it. And I don't get any error. But the output I am getting is an empty array. But I run the same code on SQL server management studio, then it does work properly and I get all the column names. Does anyone know why is this. Thank you.

 

SQL cannot get Column names problem.jpg

0 Kudos
Message 1 of 10
(1,822 Views)

Stack overflow suggests 

select *
from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME='tableName'
G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 10
(1,802 Views)

No, that doesnt work either. I also used EXEC sp_columns 'Kokam_List' but doesnt work. EXEC sp_columns 'Kokam_List' also works in SQL server management studio but not in LabVIEW.

 

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

My first thought was that it was a difference in bitness between LabVIEW and SSMS, but you didn't get an error.  My second thought is to try double-quotes instead of single, i.e. "Kokam_List" instead of 'Kokam_List'.  I'm not super confident that this will make the difference, but I've seen weirder things before.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 4 of 10
(1,775 Views)

Nope, double quotes is giving an error. 

0 Kudos
Message 5 of 10
(1,770 Views)

I solved the issue. The issue was in the ODBC connection. When I created the ODBC connection one of the settings was wrong. So there is a connection and because of that no error but executing sql query is not possible. 

Message 6 of 10
(1,709 Views)

Which setting was wrong ?

I would be glad to know (and surely others) if it happens to anybody else.

0 Kudos
Message 7 of 10
(1,702 Views)

Well its the most important setting. Change the default database to. I forgot to change it to the database which I want. So the labview was just connecting to a master database in the system instead of the database I want which was really foolish.

Message 8 of 10
(1,689 Views)

@govindsankar wrote:

Well its the most important setting. Change the default database to. I forgot to change it to the database which I want. So the labview was just connecting to a master database in the system instead of the database I want which was really foolish.


I would consider this the second most important setting. The actually most important one would be the server address, port, and protocol if any. 😁

Rolf Kalbermatter
My Blog
Message 9 of 10
(1,671 Views)

@govindsankar wrote:

Well its the most important setting. Change the default database to. I forgot to change it to the database which I want. So the labview was just connecting to a master database in the system instead of the database I want which was really foolish.


It's so humbling to share stuff like this.  Thank you for sharing your solution with us.  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 10 of 10
(1,626 Views)