I have a C++ builder 5 application that uses 4 TADOConnection VCL components in an TDataModule form.
The connections "KeepConnection" property is configured as true so as to keep connected even when there are no datasets open. The application runs 24 hours a day, seven days a week but does not usually process ant data between the hours of 11 pm and 5 am. the database is an SQL Server 2005 database.
Occasionally, there is a loss of connection during the night due to external conditions and I wish to detect this event with an event handler without having to periodically perform data operations to check each connection.
The TADOConnection component has AfterDisconnect and AfterDisconnect event handlers but neither of these are triggered when a disconnection is simulated. Is there a way to detect a loss of connection via an event handler without effectively polling the connection by a read or write data operation ?
I am simulating a loss of connection by connecting the ADO connections through a VPN and disconnecting the VPN.
without effectively polling the connection by a read or write data operation ?
polling open connections could be a valid means if you want to show status information (for example count of users connected) anyhow. you could have an own thread for that purpose which would periodically would write some kind of heart beat for all the open connections to the database and would detect loss of connection in addition.
Sara
Roger Alcindor
ASKER
Thanks for your comment Sara. I had just accepted ste5an's comment before you posted yours. My alternative plan of action is what you suggested; periodically writing some data or executing some trivial stored procedure.
Sara