public DataTable RunProc(String sProcName, SqlParameter[] arrParams)
{
string sClassName = "DBAccess.RunProc";
SqlConnection objSqlConnection = null;
try
{
objSqlConnection = (SqlConnection)OpenConnection();
string sLogMessage="Executing Stored Procedure: ["+ sProcName +"] with Parameters ";
foreach(SqlParameter objParameter in arrParams)
{
sLogMessage+=objParameter.ParameterName+" = ";
sLogMessage+=objParameter.Value+" ";
}
logger.Logns(LogLevel.TraceDetail,sClassName," ",sLogMessage);
SqlCommand objSqlCommand = CreateCommand(sProcName, arrParams,objSqlConnection,null);
objSqlCommand.CommandTimeout=300;
SqlDataAdapter objSQLDataAdapter = new SqlDataAdapter(objSqlCommand);
DataSet objDataSet = new DataSet();
objSQLDataAdapter.Fill(objDataSet);
this.CloseConnection(objSqlConnection);
logger.Logns(LogLevel.TraceDetail,sClassName," ","Success Executing Stored Procedure: ["+ sProcName +"]");
this.CloseConnection(objSqlConnection);
if( objDataSet.Tables.Count>0)
{
return objDataSet.Tables[0];
}
else
{
return null;
}
//SqlParameter p= new SqlParameter("PACCOUNTNUM", IBM.Data.DB2.DB2Type.VarChar, 17, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null);
}
catch(Exception Ex)
{
logger.Logns(LogLevel.TraceDetail,sClassName," ","Error Executing Stored Procedure: ["+ Ex.ToString() +"]");
this.CloseConnection(objSqlConnection);
throw(new Exception(Ex.ToString()));
}
}
The above mentioned code executes successfully in our production enviroment however all of the sudden we start getting Error in our logs
11/04/2011 09:42:46 AM|TraceDetail
|DBAccess.RunProc
| |Error Executing Stored Procedure: [System.Threading.ThreadAbortException: Thread was being aborted. at SNINativeMethodWrapper.SNIPacketGetConnection(IntPtr packet) at System.Data.SqlClient.TdsParserStateObject.ProcessSniPacket(IntPtr packet, UInt32 error) at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParserStateObject.ReadPacket(Int32 bytesExpected) at System.Data.SqlClient.TdsParserStateObject.ReadBuffer() at System.Data.SqlClient.TdsParserStateObject.ReadByte() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at GDCIEngine.Data.PrismDb.DBAccess.RunProc(String sProcName, SqlParameter[] arrParams)]
The above mentioned code is used in a Web service which is called by presentation layer on the presentation layer i happen to recive HTTP Timedout however on the backend where the service is actually hosted the above mentioned exception is getting printed as soon as i do an iisreset on backend machine every thing start working as expected this error is showing up every now and then and iisreset being the only solution i have come up to cope up with it any help in this regard would be highly appreciated
Thanks Regards Azeem