05-15-2023 03:22 AM
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.
05-15-2023 04:09 AM
Stack overflow suggests
select *
from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME='tableName'
05-15-2023 04:12 AM
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.
05-15-2023 05:20 AM
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.
05-15-2023 05:27 AM
Nope, double quotes is giving an error.
05-16-2023 02:31 AM
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.
05-16-2023 03:10 AM
Which setting was wrong ?
I would be glad to know (and surely others) if it happens to anybody else.
05-16-2023 03:42 AM
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.
05-16-2023 04:43 AM
@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. 😁
05-16-2023 10:38 AM
@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. 🙂