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 957073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:38:30+00:00 2026-05-16T00:38:30+00:00

In the code below, the Provider object only has one instance of a DbConnection.

  • 0

In the code below, the Provider object only has one instance of a DbConnection. Each reader will reference the same connection instance. According to the Microsoft documentation, the second reader will get a second connection from the connection pool. This works correctly.

using (var reader1 as IDataReader = Provider.GetReader(sqlStatement1))
{
    while(reader1.Read())
    {
        using (var reader2 as IDataReader = Provider.GetReader(sqlStatement2))
        {
            while(reader2.Read())
            {
            //Do stuff with both statements
            }
        }
    }
}

I would like to the leave the connection open as long as I’m using the Provider object. However, I don’t want to waste connections in the connection pool. Would calling Provider.DbConnection.Close() attempt to return both connections to the pool? If so, how could I return the second connection to the connection pool?

  • 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-16T00:38:31+00:00Added an answer on May 16, 2026 at 12:38 am

    After testing different connection providers, I’ve found my answer.

    The OleDb provider maintains its connection pool different than the SqlClient provider. generally the SqlClient provider should create a new SqlConnection object each time you want to connect to the database. the connection should be closed or disposed. This releases the underlying connection into the pool.

    The OleDb provider however handled differently. Instead of instantiating a new connection each time, the same connection object should be used and disposed at the end of the application. If used the same way as the SqlClient connection, and error is thrown “Unspecified error”. Each OleDbCommand can be assigned the same OleDbConnection instance. If it is already being use, the underlying provider will assign a new connection to it. Doing this with the SqlClient provider it will generate an exception.

    My original connection string was this:
    Data Source=….mdb;Provider=Microsoft.Jet.OLEDB.4.0; This turned out to fail after 128 connections… With a very friendly “Unspecified Error”. After researching connection pooling (not the error), this parameter needed to be added to turn on connection pooling. OLE DB Services = -1;

    With this turned on, the connections behaved as expected and no limit was reached.

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

Sidebar

Ask A Question

Stats

  • Questions 463k
  • Answers 463k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer 420 could be anything. It could be 42.0 F (which… May 16, 2026 at 12:38 am
  • Editorial Team
    Editorial Team added an answer XmlDocument has a Load method which takes a filename, but… May 16, 2026 at 12:38 am
  • Editorial Team
    Editorial Team added an answer Looks more like a server issue to me. Is mod_security… May 16, 2026 at 12:38 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.