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

  • Home
  • SEARCH
  • 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 6651165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:58:41+00:00 2026-05-26T00:58:41+00:00

I have an issue on a codebit with an ASP.NET Webforms 4 application. I

  • 0

I have an issue on a codebit with an ASP.NET Webforms 4 application.
I am using SQL server 2008 R2, IIS 7, the website is running on Windows Server 2008 R2 in separate Application pool (integrated mode, .NET4, with support for 32bit assemblies).

The following code is posing problems:

Dim sqlCmd = New SqlClient.SqlCommand
With sqlCmd
    Using sqlConnectionToUse As SqlClient.SqlConnection = GetActiveConnexion(pstrConnectString), _
        vAdaptor As New SqlClient.SqlDataAdapter

            .Connection = sqlConnectionToUse

            .CommandText = pstrSQL 'function parameter

            vAdaptor.SelectCommand = sqlCmd
            'query1: SELECT somecolumn FROM table WHERE somecolumn '' ==> opens a new connection in SQL Server
            'query2: SELECT someothercolumn FROM anothertable WHERE someothercolumn 23 ==> uses my WebSite process active connection
            vAdaptor.Fill(vDataSet)
    End Using
End With

UPDATE: the GetActiveConnexion() method simply does the following code in my case:

Return New SqlClient.SqlConnection("my connection string obtained from the web.config file")

When I run the query2, everything goes smoothly, the ASP.NET application uses the openned connection of the application pool and I get my results in the dataset.

However, whenever I run the query1, a NEW connection is openned in SQL server (I can see it show up in the SSMS’s Activity Monitor) and this one remains openned. The problem is that If I run this query1 100 times, I reach the connection pool’s limit and very bad things happens. I still gets the results in the dataset, can use them etc…
The new connection is created on the call of vAdaptator.Fill().

Any idea on what’s wrong ?

Thanks a lot for your time.
(PS: sorry for the bad english).

Here is the code in C# for those who prefer:

object sqlCmd = new SqlClient.SqlCommand();
using (SqlClient.SqlConnection sqlConnectionToUse = GetActiveConnexion(pstrConnectString)) {
    using (SqlClient.SqlDataAdapter vAdaptor = new SqlClient.SqlDataAdapter()) {

        sqlCmd.Connection = sqlConnectionToUse;

        sqlCmd.CommandText = pstrSQL; //function parameter

        vAdaptor.SelectCommand = sqlCmd;
        //query1: SELECT F10_ID FROM FIN_MONTANT_TT_F10 WHERE F10_ID_TT_F19 = '' ==> opens a new connection in SQL Server
        //query2: SELECT A48_ID FROM ADH_EPARTICIPANT_ADMIN_A48 WHERE A48_ID=23 ==> uses my WebSite process active connection
        vAdaptor.Fill(vDataSet);
    }
}
  • 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-26T00:58:42+00:00Added an answer on May 26, 2026 at 12:58 am

    Your SqlCommand instance should be wrapped in a using block as it’s Disposable. It’s probably the source of your problems.

    using (SqlClient.SqlConnection sqlConnectionToUse = GetActiveConnexion(pstrConnectString)) 
    {
        using (SqlCommand sqlCmd = sqlConnectionToUse.CreateCommand())
        {
            using (SqlClient.SqlDataAdapter vAdaptor = new SqlClient.SqlDataAdapter()) 
            {
                ...
            }
        }
    }
    

    Or VB

    Using sqlConnectionToUse As SqlClient.SqlConnection = GetActiveConnexion(pstrConnectString)
        Using sqlCmd As SqlCommand = sqlConnectionToUse.CreateCommand()
            Using vAdaptor As New SqlClient.SqlDataAdapter()
                    ...
            End Using
        End Using
    End Using
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed an application using Entity Framework , SQL Server 2000, Visual Studio
We have an issue using the PEAR libraries on Windows from PHP . Pear
We have an issue related to a Java application running under a (rather old)
I have a requirement in SQL Server 2008 in development database Only DBA's (
I have an issue with the static method in ASP.NET. I created the Singleton
I have an issue that is driving me a bit nuts: Using a UserProfileManager
I have an issue with using AWK to simply remove a field from a
I have big issue with url-rewriting for IIS 7.0. I've written simple module for
I have issue wuth Firefox not displaying style text-decoration: line-through. I am using jqGrid
Much of my sql code is generated (from POD). Now i have issue where

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.