LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatic reconnect MS Sever SQL connection

Solved!
Go to solution

Dear colleagues,

 

Please help me about how can I do the automatic reconnect SQL server connection after lost.

 

Now the "DB open connection" I did at once before "while loop" and I don't want put into "while loop" in order to leave growth memory consumption

 

 

0 Kudos
Message 1 of 7
(7,884 Views)

Opening the connection in the while loop should not increase memory consumption, provided you close  each connection after use.

In your case you could close and reopen the connection in the while loop only if an error has been detected.

 

I usually avoid keeping a connection open it not strictly needed: I prefer to open-use-close the connection each time.

Regards,

Marco

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

Dear Marco

With your "open-use-close connection" how much long application works?

 

Simply my application is working in 24/7  (Smiley Happy)  and I try to minimize memory consumption...   Unfortunately LV can't working in uninterrupt mode

 

 

0 Kudos
Message 3 of 7
(7,858 Views)

THe overhead for the open/close is very little. We have not observed any issues when using this method.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 7
(7,856 Views)

Opening/closing the connection to a database placed in our local network takes e few ms.

Since we are executing queries about once every 30s we chose the open-query-close approach (which has a "bult-in retry" in a certain sense...)

 

A look here could help confusing the ideas about what's better 🙂 :

 

http://stackoverflow.com/questions/312702/is-it-safe-to-keep-database-connections-open-for-long-time

 

Regards,

Marco

0 Kudos
Message 5 of 7
(7,851 Views)
Solution
Accepted by Current_93

We were closing and opening a connection every time and we decided to change because the virtual memory increases considerably. So,  we opened the connection before the while inserting a case inside the while which detects an error with the communication and if thats the case reconnect the communication.

0 Kudos
Message 6 of 7
(7,825 Views)

how about a SQL state machine, see attached

Download All
0 Kudos
Message 7 of 7
(6,083 Views)