Successfully Close ODBC Connections

Successfully Close ODBC Connections

The Microsoft Access engine will maintain a persistent connection onan ODBC connection in order to be more efficient, even after using a Closemethod on a database opened with ODBC. The ODBC database process keepsrunning. To close the connection successfully, you must end the VisualBasic application. Even though this is by design, many times the connectionis unwanted. One way to force the connection closed is to set ConnectionTimeoutto the minimum setting of one second. A setting of zero indicates to neverclose the connection. It is defaulted to a value of 600 seconds, or 10minutes. If a Visual Basic program does not reopen the ODBC connectionafter doing a Close method, a timeout occurs and the connection closesautomatically. You can control the timeout period by placing the followingline in your VB.INI or .INI file, where x is thenumber of seconds:

 [ODBC]ConnectionTimeout=x

To enforce the fastest possible timeout, you can set ConnectionTimeoutto one. In addition, you can add this code after you close the databaseto make sure the connection is terminated:

 db.Close	' Close database, using 			' database object variable (db).Start = TimerDo			' This loop pauses a second 			' to allow a time-out	FreeLocks	' Tell Microsoft Access 			' engine that program is idle.	DoEvents	' Tell Windows to do any 			' pending events.Loop While Timer <= Start + 1

This loop delays for a second after the db.Close. The FreeLocks statementtells the database engine that the user is idle. If you run the VisualBasic program with ConnectionTimeout set to one in your VB.INI or .INIfile, the database engine will disconnect the one-second-old connectionto the server.

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

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes