472,328 Members | 1,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 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 5244

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...
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...
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...
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...
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...
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....
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...
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...
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...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.