2007年4月27日 星期五

對於Timeout expired , 加長SQL 的Timeout時間

由於資料量較大, 產生以下的錯誤訊息:
Server Error in '/' Application.
--------------------------------------------------------------------------------

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
我目前的解決方法是:
1. select的語法裡 from 裡面記得加讓 WITH (nolock) , 如: select name FROM product WITH (nolock) 對資料的抓取有明顯的速度改善
2. 設定SQL selecting的CommandTimeout的時間, 加長一點點試試
System.Data.Common.DbCommand dbCommand = DaTaBase.GetStoredProcCommand(sqlCommand);
dbCommand.CommandTimeout = 60; //60秒 =1分鐘
加長SQL 的Timeout時間

沒有留言: