收到错误说:
"超时已过期。操作完成之前经过的超时时间或服务器没有响应。" 它获得了700条记录,但需要45秒。我认为是这个问题。 在此代码中如何添加cmd.CommandTimeout = 60;
我的代码是:
Dap_Proj = new SqlDataAdapter("select LinkId,LinkName,CategoryId, ReportLinks,SubmissionStatus,convert(nvarchar(18),LnkSubmsnDate) as LnkSubmsnDate, convert(nvarchar(18), LnkUpdateDate) as LnkUpdateDate,LnkSubmtdBy,K.KeyWord,RenewalDate from tbl_Link L left join Tbl_keywords K on L.KeywordID=K.KeywordID where
(SubmissionStatus='Approved'or SubmissionStatus='Waiting for Approval') and LnkSubmtdBy='" + Session["LoginUser"].ToString() + "' and Convert(Char(4),LnkSubmsnDate,100) in (select Convert(Char(4),LnkSubmsnDate,100) from tbl_Link )order by case when RenewalDate is null then 1 else 0 end,RenewalDate", connection);
ds = new DataSet();
Dap_Proj.Fill(ds);
答案 0 :(得分:1)
要在sqlDataAdapter上设置命令超时,请尝试以下
SqlDataAdapter Dap_Proj = new SqlDataAdapter(strSQLString, conUS);
Dap_Proj .SelectCommand.CommandTimeout=120;