Database exception Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. code example
Example 1: System.Data.SqlClient.SqlException: 'Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.' SqlDataAdapter
private void FillInDataGrid(string SQLstring)
{
string cn = ConfigurationManager.ConnectionStrings["Scratchpad"].ConnectionString;
DataSet ds = new DataSet();
using(SqlConnection myConnection = new SqlConnection(cn))
{
SqlDataAdapter dataadapter = new SqlDataAdapter(SQLstring, myConnection);
dataadapter.SelectCommand.CommandTimeout = 60;
myConnection.Open();
dataadapter.Fill(ds, "Authors_table");
}
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "Authors_table";
}
Example 2: execution timeout expired the timeout
using (SqlCommand sqlCmd = new SqlCommand(sqlQueryString, sqlConnection))
{
sqlCmd.CommandTimeout = 0;
...
}