Checking for a lost connection

Checking for a lost connection

I want to periodically check to see if a user’s database connection has been lost. How can I?

First of all, a solution. You can implement periodic ‘polling’ actions by either using the timer OCX on Windows platforms for Version 2, or you can take advantage of the TestCommand() method, which executes several times a second. You can declare a static counter variable and check for the connection every n times. Using the TestCommand() method for any type of complex processing can degrade overall system performance, so use it with care.

The only way to check for an existing database connection is to fire off a SQL statement. You can’t simply test the connection with the IsConnected() method of the session, since that will simply check to see if the client application thinks it’s connected.

However, I would personally advise against using a polling process for this type of check. Why bother to fire off a SQL statement just to test a connection? An easier way to handle this would be to put code into the DBError() method to handle a lost connection. If there is any error in the automatic database access, it will fire the DBError() method, so you can be sure of catching the problem if it occurs. Besides, why bother checking for a lost connection if the user may not even need to access the database? In a client/server system, it’s best to lay back and react to the user’s actions.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several