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: 

Database error

Solved!
Go to solution

I am running a vi which is attached herewith. No problem is there in that vi and it is running succesfully. But if I run it continuously for 16-17 hours, the execute query block gives an error and so on no data is uploading to the .txt file so from then the the output array contains all zeros.Then after restarting the vi, it is working fine. Why it is happening? How to resolve it?

Download All
0 Kudos
Message 1 of 7
(2,784 Views)

what is the error given by the query function ?

0 Kudos
Message 2 of 7
(2,769 Views)

The error is in database connection error. Actually I have not note down the error code, most probably the error code is -2146476259. Without running it for the 16-17hrs, it is not giving the error. So, for cofirmed error code, we have to wait again.

0 Kudos
Message 3 of 7
(2,763 Views)

Sorry I have written the wrong error message code. The right one is -2147467259. The error is in database connection. I have attached herewith the screen shot of the error.

Download All
0 Kudos
Message 4 of 7
(2,741 Views)
Solution
Accepted by topic author LSG

The text reported in your error lead me to this:

 

http://dev.mysql.com/doc/refman/5.5/en/gone-away.html

 

Your sample code looks for a change of "numeric" to a value of 1. When the value changes to "1", you query the DB and write the results to a file.

 

If numeric doesn't change for an extended period of time (>8 hrs) then maybe MySQL is closing the connection on the remote side. When numeric finally does change to a value of "1", the connection no longer exists and DB Tools reports the error.

 

By default, the server closes the connection after eight hours if nothing has happened. You can change the time limit by setting the wait_timeout variable when you start mysqld. See Section 5.1.4, “Server System Variables”.

 

The simple way to handle this would be to retrieve something simple from the DB such as a table list to keep the connection open.

 


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

Message 5 of 7
(2,729 Views)

I agree with PhillipBrooks.

You may consider to open/query/close the connection to DB each time.

 

See here for a discussion on the topic:

http://forums.ni.com/t5/LabVIEW/Automatic-reconnect-MS-Sever-SQL-connection/m-p/2146220

 

Moreover, since your code is running for such a long time I would strongly suggest to implement a reconnect method. Otherwise if the connection is lost it will NEVER be recovered.

 

Regards,

Marco

0 Kudos
Message 6 of 7
(2,714 Views)

Thank you for your reply. I have understood. The problem is solved.

0 Kudos
Message 7 of 7
(2,688 Views)