Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6025829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:21:25+00:00 2026-05-23T04:21:25+00:00

I have to work with a Project made by another developer. A project Win-Form

  • 0

I have to work with a Project made by another developer. A project Win-Form with Visual-Basic code, with MS-Access as db and some OleDbConnections. There is a bug: sometimes the application can’t open the OleDbConnection because the max number of connections has been reached on the db. I know the best way to use the connections is this:

Using cn As New OleDbConnction(s)
  ...
  cn.Close()
End Using

But in the project there are many classes to work with the db, and in many of these classes there are OleDbConnections with “Friend” visibility, that are opened and closed in different times. For this reason it’s impossible to put all the OleDbConnections in a Using construct, and it’s very very hard to find what operation “forgets” to close one of these OleDbConnection.

A possible solution could be to use only one unique public OleDbConnection, and to check, before opening it, if it isn’t already opened.
But someone have told me it’s a very bad practice. I suppose he told me this about the performance, but I don’t know it exactly.
Can you tell me why one unique public OleDbConnection is so deprecated?
Have you got, for me, an “easy” solution for my problem?
Thank you,
Pileggi

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:21:26+00:00Added an answer on May 23, 2026 at 4:21 am

    From your description, I see a couple of possible issues that could result in your problem:

    • nested connections:
      You open multiple connections within each-other
    • open/release connections too fast:
      As David-W-Fenton mentionned, with access, every time you open/close a single connection, the lock file will be created/removed. This operation is quite slow and if you quickly open/close the database within you application (execute lots of atomic queries), you may get this issue.

    A few possible ways to investigate and solve the issue:

    Trace all open/close calls
    Add some debug traces that show every time you open and close a connection.
    It will allow you to detect nested connections and where your connection pool is being wasted.

    Force connection polling
    An easy ‘fix’ may be to explicitely set connection pooling in your connection string. It should be the default behaviour, so maybe it won’t do anything to solve your problem, but it’s so simple that there is no reason not to try it:

    OLE DB Services=-1
    

    Use a connection manager class to create/release connections for you.
    Replace all the explicit creations of new OleDbConnection and close operations by your own code.
    This would allow you to always re-use a single existing connection throughout your application and allow you to quickly make tweaks for the whole of your app by centralising the behaviour in a single place.

    So why holding a single connection is generally deprecated?

    • Generally, you should not keep connections open throughout your application as they force the database server to keep resources available for you, and it decreases the number of client that can connect (there is always a limited number of connections available).
      For Access though -a file-based database without server part- keeping a single connection open is actually preferable because of the delay associated with opening new connections (creation of the lock file). Since Access is not meant to be used with a large number of concurrent users, the resource cost of keeping the connection open is not significant enough to be an issue.
      From simple tests, it can be shown that keeping a connection always open allows subsequent connections to open about 10x faster!

    • The OleDb driver does connection pooling for you, so it is able to re-use connections when they are freed.

    • By keeping your connections and database operations small and contained, you would be less likely to run into concurrency issues when using threads. Keeping a global connection may become an issue if you are executing multiple operations using the same pipeline to the database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.