09-07-2012 04:14 AM
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?
Solved! Go to Solution.
09-07-2012 06:33 AM - edited 09-07-2012 06:34 AM
what is the error given by the query function ?
09-07-2012 07:01 AM - edited 09-07-2012 07:02 AM
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.
09-10-2012 11:32 PM
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.
09-11-2012 06:14 AM
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.
09-11-2012 08:37 AM - edited 09-11-2012 08:37 AM
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
09-13-2012 12:34 AM
Thank you for your reply. I have understood. The problem is solved.