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();

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Technorati
  • Reddit
  • Facebook
  • Google
  • Live
  • YahooMyWeb
  • Furl
  • Slashdot
  • Spurl
  • Mixx
  • BlinkList
  • Bumpzee