Hi All,
I am facing the time out and object reference not to set an instance of an object when running an C# exe from the job . The application runs the querries and saves the results as CSV . This issue is happening only some times and not always.
-- Few other things I noticed:
Command.commandtimeout=600
Using SQLreader to store the resultant query.
I have ran the profiler and to find out any deadlock or long running querries but I didnt find any. Tried to run the each and every query to check the timings and are running below 5 secs and command time out is 10 S.
Following is the error which we got when running the exe :
'
Message : Timeout expired. The timeout period elapsed prior to completion of th
e operation or the server is not responding.
Inner :
Source : .Net SqlClient Data Provider
Stack : at System.Data.SqlClient.SqlConnection.OnError(SqlException excepti
on, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception
, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cm
dHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, Tds
ParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, Run
Behavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBe
havior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehav
ior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult
result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehav
ior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, S
tring method)
at System.Data.SqlClient.SqlCommand.ExecuteReader()
at ABC_Ad_Hoc_Emailer.Program.Run_Report() in F:\ABC_code\Ad Hoc Emailer\ABC
Ad Hoc Emailer\ABC Ad Hoc Emailer\Program.cs:line 209
Message : Object reference not set to an instance of an object.
Inner :
Source : ABC XYZ Emailer
Stack : at ABC_Emailer.Program.Send_Mail(String contents) in F:\ABC_
code\Ad Hoc Emailer\ABC Ad Hoc Emailer\ABC Ad Hoc Emailer\Program.cs:line 455
at ABC_XYZEmailer.Program.Main(String[] Args) in F:\ABC_code\XYZ Email
er\ABC XYZ Emailer\ABC XYZ Emailer\Program.cs:line 153
'
Following is the code at 209 line(highlighted with bold letters):
SqlConnection db_Conn = new SqlConnection(connstring);
db_Conn.Open();
<pre>SqlCommand command = new SqlCommand(Query, db_Conn);
command.CommandTimeout = 600;
<big>SqlDataReader Results = command.ExecuteReader();</big>
Can any one please help me in finding out the root cause.
Regards
Prashant