c#执行sql超时

超时分为多种,SqlConnection有超时选项,

SqlDataAdapter也有超时选项设置如下:

SqlConnection:就用链接字符串给予的Timeout设置就行单位秒;

SqlDataAdapter:sqlDataAdapter.SelectCommand.CommandTimeout = 120;//就是120s了

要用SqlDataAdapter,这个要单独设定TimeOut,连接字符串的TimeOut对它是不起效的