X
X_Factor
I wrote and re-wrote this thing seven times and I still get the same
error.
options, Boolean& isInTransaction)
after about four or five transactions on my ASPX page. Here is my
code for my data access layer.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace SiteTools
{
/// <summary>
/// This class will serve to connect to the database.
/// </summary>
///
public class DB
{
protected SiteTools.Email oEmail = new SiteTools.Email();
private SqlConnection oConnection;
private SqlDataAdapter oDataAdapter;
private string Message;
// Constructor
public DB()
{
try
{
oConnection = new
SqlConnection(ConfigurationSettings.AppSettings["Connection"].ToString());
oConnection.Open();
}
catch (Exception ex)
{
// error handling
code
}
}
public SqlCommand ExecuteCommand(string sql)
{
try
{
SqlCommand oCommand = new SqlCommand(sql, oConnection);
oCommand.CommandType = CommandType.Text;
return oCommand;
}
catch (Exception ex)
{
//error handling code
return null;
}
finally
{
oConnection.Close();
}
}
public DataTable GetData(SqlCommand oCommand)
{
DataTable oTable = new DataTable();
oDataAdapter = new SqlDataAdapter();
oDataAdapter.SelectCommand = oCommand;
try
{
oDataAdapter.Fill(oTable);
}
catch(Exception ex)
{
// error
handling code
}
finally
{
oDataAdapter.Dispose();
}
return oTable;
}
~DB()
{
oConnection = null;
oDataAdapter = null;
oEmail = null;
}
}
}
What am I doing wrong????? Line 27 is the oConnection.Open();
error.
Timeout expired. The timeout period elapsed prior to obtaining a
connection from the pool. This may have occurred because all pooled
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionStringconnections were in use and max pool size was reached.
at
options, Boolean& isInTransaction)
at System.Data.SqlClient.SqlConnection.Open()
at SiteTools.DB..ctor() in c:\c# projects\sitetools\db.cs:line 27
after about four or five transactions on my ASPX page. Here is my
code for my data access layer.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace SiteTools
{
/// <summary>
/// This class will serve to connect to the database.
/// </summary>
///
public class DB
{
protected SiteTools.Email oEmail = new SiteTools.Email();
private SqlConnection oConnection;
private SqlDataAdapter oDataAdapter;
private string Message;
// Constructor
public DB()
{
try
{
oConnection = new
SqlConnection(ConfigurationSettings.AppSettings["Connection"].ToString());
oConnection.Open();
}
catch (Exception ex)
{
// error handling
code
}
}
public SqlCommand ExecuteCommand(string sql)
{
try
{
SqlCommand oCommand = new SqlCommand(sql, oConnection);
oCommand.CommandType = CommandType.Text;
return oCommand;
}
catch (Exception ex)
{
//error handling code
return null;
}
finally
{
oConnection.Close();
}
}
public DataTable GetData(SqlCommand oCommand)
{
DataTable oTable = new DataTable();
oDataAdapter = new SqlDataAdapter();
oDataAdapter.SelectCommand = oCommand;
try
{
oDataAdapter.Fill(oTable);
}
catch(Exception ex)
{
// error
handling code
}
finally
{
oDataAdapter.Dispose();
}
return oTable;
}
~DB()
{
oConnection = null;
oDataAdapter = null;
oEmail = null;
}
}
}
What am I doing wrong????? Line 27 is the oConnection.Open();