I have a data module with a global TADOConnection (with the default KeepConnection set the true).
There are numerous datasets and queries in my existing application that use this global TADOConnection.
I was wondering if there is some smart way to resume/retry the ado connection in case of a short network disconnection? (this situation happens sometimes with clients who have a not so stable connections).
Its easy to reproduce what I need. simply open TADOConnection on start-up. open some TADODataSet, and then disable and enable your "Local Area Connection". if you try to refresh the dataset, an EOleException exception is raised
"Connection failure"
or
"[DBNETLIB][ConnectionWrite (send()).]General network error. Check your network documentation"
If I restart the application all is good.
No events are fired by the TADOConnection at the time of network disconnections. and TADOConnection.Connectedremains true
of course I could use a try/catch for every TDataSet.Open or Execute but I'm looking for some "centralized" solution for my large application.
so in case of "Connection failure" I could know which dataset is trying to open, and retry.
The idea could be to catch the connection error then manage it with retries. The Suggestion:
This function returns the exception descripion
this is a simple idea to test!
A good solution is centralize the insert/update and select procedure, then catch the error and try to adjust the situation one or two times before show message to the user