0
在使用C#.NET,Windows Forms的程序中是否有增加查詢執行超時的可能性?如何增加查詢時間?
在我的程序中,我正在循環中執行查詢。在前兩次迭代中,查詢每次以10秒執行。在第三次迭代中,查詢完成大約需要40到50秒,而現在我無法從該查詢中提取數據,因爲會引發超時異常,並且執行流程將轉到catch
塊,其中相應的錯誤消息被展示。
在Windows應用程序中使用C#.NET執行查詢需要30秒以上的查詢嗎?
下面是我的代碼:
try
{
tab = "dbo.basic_sp_mst";
error1 = "" + site + "." + orgname + "";
ls = "" + site + "." + site + "." + tab + "";
SqlDataAdapter da2 = new SqlDataAdapter("select * from " + ls + " where (last_updated_date between(getdate()-3) and (getdate()-1)) order by last_updated_date,bsp_item_cd", con);
DataSet ds2 = new DataSet();
da2.Fill(dt5);
dt6 = dt5;
SqlDataAdapter daa = new SqlDataAdapter("select a. bsp_item_cd ,a.bsp_mrp,a.last_updated_date,b.bsp_item_cd ,b.bsp_mrp,b.last_updated_date,c.name from basic_sp_mst a," + ls + " b,sys.servers c where a.bsp_item_cd = b.bsp_item_cd and a.bsp_mrp<> b.bsp_mrp and a.bsp_org_cd=" + s + " and c.name<>'001' and c.name='" + site + "'", con);......................(this is the main query) if this query is taking more than 30sec it is going to catch block.......
DataSet dss = new DataSet();
daa.Fill(dt7);
dt8 = dt7;
}
catch (Exception ex)
{
msg2 = " query time out error at store id:" + error1 + "";
dataGridView8.Rows.Add(msg2);
}
查詢............ – ariel 2011-05-09 04:54:46