ADo.NET中的连接超时

时间:2015-03-16 14:21:27

标签: c# ado.net

using (SqlConnection Connect = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["templateconnection"].ConnectionString))
       {
        string strQuery = "update ActionAudits set ChecksumValue=( select CHECKSUM(Id,DateAndTimeOfAction,ActionType,RecordType,ReferenceNumber,UserFk,LocationFk,PatientFk,IPAddress) from ActionAudits with(nolock) Where Id=" + id + ")where Id=" + id;
            SqlCommand cmdChecksumValue = new SqlCommand(strQuery, Connect);
            Connect.Open();
            value = Convert.ToInt32(cmdChecksumValue.ExecuteNonQuery());
            Connect.Close();
        }

执行Convert.ToInt32(cmdChecksumValue.ExecuteNonQuery())时 它显示

错误:连接超时错误

1 个答案:

答案 0 :(得分:0)

将cmdChecksumValue .CommandTimeout设置为更大的数字。默认值为30秒。