473,326 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Connection Pooling Problem?

Bob
I have an ASP.NET web application that has been running without any problems for a while. I recently transferred the site to shared hosting and had multiple users start to use the site. The problem I'm experiencing is that when many users are hitting the site at once, occasionaly I will see errors. The 3 most common ones are: "The SqlCommand is currently busy Open, Fetching. ", "Internal Connection Fatal Error", "object reference not set to an instance of an object"

In addition, occassionally the application will lockup for hours after one of these errors. I can navigate to pages, but I cannot log in to my application - I get a "request timed out" error. It usually seems to go away after a few hours - but obviosuly this is very weird behavior

The research I have done so far indicates that the "The SqlCommand is currently busy Open, Fetching." error usually occurs because a connection that was not properly closed is returned to the connection pool or is accessed when it is still outside the pool (and open) because multiple users are hitting it at the same time. The article I've seen about this (http://www.experts-exchange.com/Prog..._20942137.html) mentioned someone putting his data access components in a module, and the accepted solution was to put everything in a class.

However, the Data Access Layer design I'm using has worked in several other multi-user web applications, so it is odd that this is happening. I am using InProcess session state, and other than that I don't know what other configuration setting might be affecting this. Could this be an IIS or hardware configuration problem? It is impossible to replicate this in debug mode because it only happens when multiple users hit the system. Anyway, thanks in advance for the help

Here is one of the methods where the "SqlCommand is currently busy Open, Fetching" error occurred

public void GetAllRestaurantsByGroup(RestaurantCollection col, int groupid

tr

Connect()

PrepareCommand("Restaurant_Select_All_By_Group")
m_dsoCommand.AddParameters("@group_id", groupid)
return m_dsoCommand.ExecuteReader()
while (m_sqlReader.Read()

Restaurant oRestaurant = new Restaurant()
oRestaurant.RestaurantName = (string)m_sqlReader["restaurantname"]
oRestaurant.GroupID = (int)m_sqlReader["groupid"]
oRestaurant.LastVisit = (System.DateTime)m_sqlReader["lastvisit"]
oRestaurant.Description = (string)m_sqlReader["description"]
oRestaurant.Distance = (double)m_sqlReader["distance"]
oRestaurant.MapURL = (string)m_sqlReader["MapURL"]
oRestaurant.DBBacked = true
col.Add(oRestaurant)
catch(Exception e

throw e
}
finall

Disconnect()

The code called by this method is below

protected DSOConnection m_dsoConnection
protected SqlDataReader m_sqlReader

public void Connect(

tr

m_dsoConnection.Open()
catch(Exception e

throw e

public void Disconnect(

tr

if (m_sqlReader != null && !m_sqlReader.IsClosed

m_sqlReader.Close()
m_dsoConnection.Close()
catch(SqlException e

throw e

protected virtual void PrepareCommand(string sStoredProcedure

tr

m_dsoCommand.CommandText = sStoredProcedure
m_dsoCommand.Connection = m_dsoConnection.Connection
m_dsoCommand.CommandType = CommandType.StoredProcedure
m_dsoCommand.ClearParameters()

catch(Exception exp

throw exp

Finally, my custom DSOConnection and DSOCommand classes are defined below

public class DSOConnectio

#region field

private string m_connectionString = null;
private SqlConnection m_connection = null;

#endregion

#region properties
public SqlConnection Connection
{
get
{
return m_connection;
}
}

#endregion

#region methods
#region construction/destruction
public DSOConnection(string connection)
{
m_connectionString = connection;
m_connection = new SqlConnection(m_connectionString);
}

#endregion

#region open/close
public void Open()
{
try
{
if(m_connection.State!=ConnectionState.Open)
{
m_connection.Open();
}
}
catch(Exception e)
{
throw e;
}
}

public void Close()
{
try
{
if(m_connection.State!=ConnectionState.Closed)
{
m_connection.Close();
}

}
catch(SqlException e)
{
throw e;
}
}
#endregion

#endregion
}

public class DSOCommand
{
#region fields

private SqlCommand m_sqlcommand = null;

#endregion

#region constructors

public DSOCommand()
{
m_sqlcommand = new SqlCommand();
}//End of DSOCommand constructor
#endregion

#region Properties

public int CommandTimeOut
{
get
{
return m_sqlcommand.CommandTimeout;
}
set
{
m_sqlcommand.CommandTimeout = value;
}
}

public string CommandText
{
get
{
return m_sqlcommand.CommandText;
}
set
{
m_sqlcommand.CommandText = value;
}
}
public SqlConnection Connection
{
get
{
return m_sqlcommand.Connection;
}
set
{
m_sqlcommand.Connection = value;
}
}

public CommandType CommandType
{
get
{
return m_sqlcommand.CommandType;
}
set
{
m_sqlcommand.CommandType = value;
}
}

public SqlParameterCollection Parameters
{
get
{
return m_sqlcommand.Parameters;
}
}//End of CommandType

#endregion

#region methods

public void ClearParameters()
{
m_sqlcommand.Parameters.Clear();
}//End of ClearParameters

public void AddParameters(string sParameterName, object oValue)
{
if(oValue != null)
{
m_sqlcommand.Parameters.Add(sParameterName,oValue) ;
}
else
{
m_sqlcommand.Parameters.Add(sParameterName,DBNull. Value);
}
}//End of AddParameters

public void AddParameters(string sParameterName, object oValue, ParameterDirection pdir)
{
SqlParameter p = new SqlParameter(sParameterName, oValue);
p.Direction = pdir;

if(oValue != null)
{
m_sqlcommand.Parameters.Add(p);
}
else
{
p.Value = DBNull.Value;
m_sqlcommand.Parameters.Add(p);
}

}//End of AddParameters

public SqlDataReader ExecuteReader()
{
return m_sqlcommand.ExecuteReader();
}//End of ExecuteReader

public int ExecuteNonQuery()
{
return m_sqlcommand.ExecuteNonQuery();
}//End of ExecuteNonQuery

#endregion
}
I have also included the full text of the error below:
Server Error in '/' Application.

--------------------------------------------------------------------------------

The SqlCommand is currently busy Open, Fetching.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The SqlCommand is currently busy Open, Fetching.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:
[InvalidOperationException: The SqlCommand is currently busy Open, Fetching.]
LunchinatorBusinessLayer.Data.Manager.RestaurantMa nagerDSO.GetAllRestaurantsByGroup(RestaurantCollec tion col, Int32 groupid) in C:\Documents and Settings\Bob\My Documents\Visual Studio Projects\Lunchinator\LunchinatorBusinessLayer\Data \Manager\RestaurantManagerDSO.cs:266
LunchinatorBusinessLayer.Business.Collection.Resta urantCollection.GetAllRestaurantsByGroup(Int32 groupid) in C:\Documents and Settings\Bob\My Documents\Visual Studio Projects\Lunchinator\LunchinatorBusinessLayer\Busi ness\Collection\RestaurantCollection.cs:67
Lunchinator.Main.Results.SetMostVotes() in c:\inetpub\wwwroot\Lunchinator\Main\Results.aspx.c s:92
Lunchinator.Main.Results.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\Lunchinator\Main\Results.aspx.c s:68
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

Jul 21 '05 #1
0 5341

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Harry | last post by:
Using Oracle 8i enterprise on win 2000 (sp3) Installed the standard configuration & whenever I make a connection it takes about 10 secs. It's running on a P1900 with 1gb Ram so no reason there...
5
by: John | last post by:
Does COM.ibm.db2.jdbc.DB2DataSource, (which supports connection pooling) need to be run within a J2EE container environment before the connection pooling facility is actually available to a user? ...
1
by: Mark | last post by:
I know that DB2 LUW version 8 has "connection pooling" that provides a connection concentrator (limits the number of simultaneous connections that can occur). But does it really provide connection...
6
by: Chris Szabo | last post by:
I've created a data access layer for a .NET web application. I'm using C# and framework 1.1. I'm getting an error from time to time when I close a connection saying: ...
1
by: Lenny Shprekher | last post by:
Hi, I am getting issues that Oracle collecting opened sessions (connections) from my webservice using regular System.Data.OleDb.OleDbConnection object. I am guessing that this is connection...
3
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database...
3
by: howachen | last post by:
Hi, Is that when using pconnect to mysql, it is already mean connection pooling? thanks.
16
by: crbd98 | last post by:
Hello All, Some time ago, I implemented a data access layer that included a simple connectin pool. At the time, I did it all by myself: I created N connections, each connection associated with...
20
by: fniles | last post by:
I am using VS2003 and connecting to MS Access database. When using a connection pooling (every time I open the OLEDBCONNECTION I use the exact matching connection string), 1. how can I know how...
0
viswarajan
by: viswarajan | last post by:
Introduction This article is to go in deep in dome key features in the ADO.NET 2 which was shipped with VS 2005. In this article I will go trough one of the key features which is the Connection...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.