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.Connected
remains 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.
MyConnection.Connected := False; MyConnection.Connected := True;
For the record, our legacy software does the same thing, and upon reconnection, from what I understand, all the queries connected to it have no choice but to be refreshed (opened again) manually - so keep track of them.. – Pertain