Its the wrong way or lack of performance, using DbDataReader combinated with DbTransactions? An example of code:
public DbDataReader ExecuteReader()
{
try
{
if (this._baseConnection.State == ConnectionState.Closed)
this._baseConnection.Open();
if (this._baseCommand.Transaction != null)
return this._baseCommand.ExecuteReader();
return this._baseCommand.ExecuteReader(CommandBehavior.CloseConnection);
}
catch (Exception excp)
{
if (this._baseCommand.Transaction != null)
this._baseCommand.Transaction.Rollback();
this._baseCommand.CommandText = string.Empty;
this._baseConnection.Close();
throw new Exception(excp.Message);
}
}
Some methods call this operation. Sometimes openning a DbTransaction. Its using DbConnection and DbCommand.
The real problem, is in production enviroment (like 5,000 access/day) the ADO operations start throwing exceptions
It has an method, that doesnt open a DbTransaction, but throws the excp anyway.
EDIT: We implemented log, to analyse ADO operations. This was an approach to catch the ADO problems in production enviroment. The exceptions caught were:
There is already an open DataReader associated with this Command which must be closed first.
Invalid attempt to call Read when reader is closed.
The connection was not closed. The connection's current state is open.
Also, we realized that the dbHelper class, is instantiated this way:
private static readonly dbHelper<T> _instance = new dbHelper<T>();
public static dbHelper<T> GetInstance()
{
return _instance;
}
And the DAO's constructors, instatiate the dbHelper:
this._dataPersist =
Registro.Classes.dbHelper<System.Data.SqlClient.SqlClientFactory>.GetInstance();
We think changing the data access code, replacing the generic dbHelper with another approach, might fix the problem. Any suggestions would be appreciated.