Avatar of Roger Alcindor
Roger Alcindor
 asked on

Detecting an ADO Connection loss Event

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.
C++ProgrammingMicrosoft SQL Server 2005

Avatar of undefined
Last Comment
Roger Alcindor

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
ste5an

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
sarabande

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.

Roger
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck