Actually, that is a funny story. As I initially had the same question on how to build this into our already vast application.
The handle in our application is stored in the Applic.SQLHandle property. I ended up using the Applic.SQLHandle_Access method to execute an empty SQL Statement if the last SQL statement was more than 5 seonds ago.
When that fails on a connection error, it calls the Reconnect method with the code below is used to revive the connection.
It miraculously even worked on Remove Views (I know your fav topic :))
The method has been proven to be very robust for us.
Walter,
>Hi Walter,
>
>
> ASQLHANDLES(aSqlhndls)
> FOR EACH nOdbchdbc IN aSqlhndls
> =SQLIDLEDISCONNECT(nOdbchdbc)
> ENDFOR
>
>
>
>Nice trick. A few questions:
>
>1) Where do you put this- in a sqlexec() method or an object error method or ??
>2) Would sqldisconnect(0) suffice if you're closing them all?
>3) Do you ask the user whether to keep trying before you terminate the app?- J
>
>Regards, J