Error when Windows Returns from Sleep

I have a Windows app that connects to a MSSQL database to view/update data. My app throws an OLEException when Windows 7 returns from sleep mode. The exception occurs when I try to execute a SQL command to the database. The specific error is “{ConnectionWrite(send()).] General netwrok error. Check your network documentation., (failed on “Open”) Exception Error Number: -2147352567” It appears that connection to the database is gone, but my app doesn’t know that. I tried checking for a Nil database and checking the connection state but these are showing that the connection is still there.

Does anybody have an thoughts on how to either detect the return from sleep Windows event (then I can re-establish the connection) or catch the exception, re-establish connection, and then resume execution at the line that caused the error (is this even possible?)?

I using Xojo v2014 Release 2, Windows 7, the MSSQL connection is established using OLEObject(“ADODB.Connection”)

– Rob

Have you tried wrapping your code in a try-catch?

Is there a reason why you don’t use MSSQLServerDatabase?

I will look at a Try /Catch. Thanks.

I not using MSSQLServertDatabase as I could not get it to recognize a named instance on a MSSQL cluster and couldn’t find any examples that worked for me.

– Rob

I used the Try/Catch and was able to get it to work. I looked at Try/Catch yesterday and couldn’t figure it out. Today, it was much clearer in my mind. Thanks

– Rob