Solved

Detecting an ADO Connection loss Event

Posted on 2014-11-17
3
229 Views
Last Modified: 2014-11-18
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.
0
Comment
Question by:alcindor
3 Comments
 
LVL 33

Accepted Solution

by:
ste5an earned 500 total points
ID: 40449258
The disconnect event is called when you close the connection. There is no event for e.g. network problems. Here the old rules apply:

Don't use long living connections.

Otherwise use your own proxy implementation which is able to reconnect.
0
 
LVL 33

Expert Comment

by:sarabande
ID: 40449764
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
0
 
LVL 2

Author Comment

by:alcindor
ID: 40449817
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
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question