From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW crashes when reading JSON data from a SQL server database

Solved!
Go to solution

Hi,

 

I wrote a program to write and read from a sql server database. So the table has first 4 values in 4 columns. The 5th column value to be stored is an array of 2000 values. So I compress the complete 2000 values into 1 Json string and then store it in the 5th column. Till here the program works fine. Next I try to read the same values. So if I tried to read the first 4 columns no problem. I can easily read from them. But when it comes to the Json string labview is crashing when trying to read it. Labview is crashing without any error message. Does anyone know how can I solve this problem. I am using the SQL VIs from  hans petter halvorsen. I believe most people use that. So kindly help me in how to solve this problem of reading a Json string from a sql server database in labview. Thank you. 

0 Kudos
Message 1 of 12
(1,012 Views)

@govindsankar wrote:

I am using the SQL VIs from  hans petter halvorsen. I believe most people use that.


I don't know what this is.  I use the database library that ships with LabVIEW Professional.

 

If you have a question about your code, and if you want to receive meaningful answers about how to solve the problem with your code, you must post your code. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 12
(969 Views)

I have attached the program

SQL Select program.jpg

0 Kudos
Message 3 of 12
(885 Views)
Solution
Accepted by topic author govindsankar

What happen when you have less values to read in your Json string ?

 

I suspect a memory crash or an overflow.

0 Kudos
Message 4 of 12
(879 Views)

So instead of 2000 values, I changed to 10values and the program doesnt crash. But the value read out doesnt make any sense. This is what comes out instead of the 10 value JSON string

SQL Select program 2.jpg

0 Kudos
Message 5 of 12
(872 Views)

It looks like an ASCII string, would it be more readable as HEX ?

 

Have you tried to read your data into an SQL IDE (depends of your SQL installation : MySQL, MSSQL, etc ...) and compare what comes out ?

0 Kudos
Message 6 of 12
(868 Views)

Yes I have tried to read using sql server management  studio and it reads out exactly what it writes, a very long string value

0 Kudos
Message 7 of 12
(857 Views)

I had got no labview solution for this, so I had to find a workaround. So I created a c# application that reads from the database and stores in an Excel file, and then labview reads from the Excel file. This is the workaround, instead of labview directly reading from the database. And this workaround works fine. I use system exec.vi in labview to execute the c# application. I made sure no window pops up when the c# application is executed, so it would look like labview is itself reading directly from the database. 

0 Kudos
Message 8 of 12
(814 Views)

@govindsankar wrote:

 

I am using the SQL VIs from  hans petter halvorsen. I believe most people use that. 


Your believe definitely is not right. Most people simply use the SQL Database Toolkit from NI. Some others use other Toolkits which all are based on the ActiveX ADO/DAO or .Net Database Access interface from Microsoft.

 

And I'm using my own version which is directly accessing the ODBC API.

 

I can't comment on the VIs you are using as I have never seen them, but it would seem a safe bet that the problem is somewhere in there.

Rolf Kalbermatter
My Blog
Message 9 of 12
(807 Views)

I just downloaded the library from hans petter halvorsensql and tested it on a MySQL database and everything was ok.

 

I created a small VI which generates two 2D graphs with random numbers and a string constant and converted the data into a json string. One of the "array" elements contains 200000 samples of "time" and "data" elements and the second one with 100000 elements (in total 600000 double numbers).

Martin_Henz_0-1685712212922.png

 

The problem is not the toolkit.

Message 10 of 12
(778 Views)