22 May
Posted by Jayce as Programming
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated.
Do you face this error during SQL query in C#? Fear no more, my friend. All you need to do is put the timeout period more then default value - CommandTimeout. Follow the code below…
SqlConnection EDCConnectionString = new SqlConnection(”ConnectionString”);
EDCConnectionString.Open();
string SQLTesterStats = “StoredProcedure”;
SqlCommand cmdTesterStats = new SqlCommand(SQLTesterStats, EDCConnectionString);
cmdTesterStats.CommandType = CommandType.StoredProcedure;
cmdTesterStats.Parameters.AddWithValue(”@start”, “04-01-2007 00:00″);
cmdTesterStats.CommandTimeout = 500000;
SqlDataReader TesterStatsReader = cmdTesterStats.ExecuteReader();
DataRow NewRow;
while (TesterStatsReader.Read())
{
NewRow[”product”] = TesterStatsReader[”family_name”].ToString();
}
TesterStatsReader.Close();
EDCConnectionString.Close();
2 Responses
ujwala
December 24th, 2007 at 1:47 pm
1I have SQL CLient and try to connect to server on another machine
while executing the query using the conn class then i got the error TimeoutExpired plese help me.
Jayce
December 24th, 2007 at 2:33 pm
2Hi ujwala, have you try CommandTimeout function yet?
RSS feed for comments on this post · TrackBack URI
Leave a reply
Categories
Archives
Chat Chat Chat...
SP Blogger
Isabell Online Penang Florist