Solved

Detecting an ADO Connection loss Event

Posted on 2014-11-17
3
222 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java Loop 6 50
How can I exclude some wording in a like statement? 39 67
CROSS APPLY 4 45
simplest php form 3 64
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

862 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now