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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:57:36+00:00 2026-06-10T11:57:36+00:00

I have used my database access code as below: //gets the connection and create

  • 0

I have used my database access code as below:

//gets the connection and create transaction
SqlTransaction transaction = SelectConnection();

try
{
    dsRecordDataset = new DataSet();
    SqlParameter[] param = new SqlParameter[1];
    string[] taleNames = new string[1];
    taleNames[0] = "RecordSet";
    param[0] = new SqlParameter("@Mode", Mode);
    SqlHelper.FillDataset(transaction, CommandType.StoredProcedure, 
                          "spProject", dsRecordDataset, taleNames, param);
    transaction.Commit();
    return dsRecordDataset;
}
catch (Exception ex)
{
    transaction.Rollback();
    throw ex;
}

Problem which I have found is I have never closed the connection so that the connection pool can overflow and give an error to the user sometimes. I need to clarify the following

  1. When does the connection pool reset according to default settings in asp.net?
  2. Does committing transaction has anything to do with the connection?

I tried to use following code after try catch block

finally
{
    if (transaction.Connection.State == ConnectionState.Open)
    {
        transaction.Connection.Close();
    }
}

but then the connection is null and gives a error.

  1. Is there any way to close the connection in above code?
  • 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-06-10T11:57:37+00:00Added an answer on June 10, 2026 at 11:57 am

    when does the connection pool reset according to default settings in asp.net?

    If MinPoolSize is either not specified in the connection string or is specified as zero, the connections in the pool will be closed after a period of inactivity. However, if the specified MinPoolSize is greater than zero, the connection pool is not destroyed until the AppDomain is unloaded and the process ends.

    does committing transaction has anything to do with the connection?
    No, committing a connection does not (should not) close the connection

    is there any way to close the connection in above code?

    You can do this using either the Close or Dispose methods of the Connection object, or by opening all connections inside a using statement in C# so that they will be returned to the connection pool. Connections that are not explicitly closed might not be added or returned to the pool.

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

Sidebar

Related Questions

I have used code like this: http://msdn.microsoft.com/en-us/library/dw70f090.aspx to access database before when working in
With the following code below I have managed to open an Access.mpd database and
I have created my database, and used cake bake my_project to create my project,
I have avatars stored in a database. I have used the the data type
I used to have a situation where I hit the database a every time
I have a column in my SQL-2005 database that used to be a varchar(max)
I have a table A which references table B. edit: Database engine used is
I have a database of events that are used to fill a PHP calender.
I have a number of scripts used to build a database. These need to
I have a MySQL database includes a table named 'Task'. and I used Hibernate

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.