2015-11-03 96 views
0

我的過程是這樣的,超時已過期。之前完成上述操作超時時間已過或服務器沒有響應

sqlCmd = New SqlCommand("sp_JBM_ProductionReprt", myConnection) 
       sqlCmd.CommandType = CommandType.StoredProcedure 
       sqlCmd.Parameters.Add(New SqlParameter("@Type", Data.SqlDbType.VarChar)).Value = SessionHandler.sCustAcc 
       sqlCmd.Parameters.Add(New SqlParameter("@FromDate", Data.SqlDbType.DateTime)).Value = strFromDate 
       sqlCmd.Parameters.Add(New SqlParameter("@ToDate", Data.SqlDbType.DateTime)).Value = strToDate 
       sqlCmd.Parameters.Add(New SqlParameter("@TblChapterInfo", Data.SqlDbType.VarChar)).Value = Init_Tables.gTblChapterInfo 
       sqlCmd.Parameters.Add(New SqlParameter("@TblProdStatus", Data.SqlDbType.VarChar)).Value = Init_Tables.gTblProdStatus 
       sqlCmd.Parameters.Add(New SqlParameter("@Condition", Data.SqlDbType.VarChar)).Value = strCondition 
       sqlCmd.Parameters.Add(New SqlParameter("@EmpSelection", Data.SqlDbType.VarChar)).Value = strEmpSel 
       sqlCmd.Parameters.Add(New SqlParameter("@SubTeamID", Data.SqlDbType.VarChar)).Value = " " 

      myConnection.Open() 
      sqlCmd.Connection = myConnection 
      'sqlCmd.CommandTimeout = 10 
      myReader = New SqlDataAdapter(sqlCmd) 

      myReader.Fill(ds) 

在等待不到一分鐘,我得到這個錯誤

the timeout period elapsed prior to completion of the operation or the server is not responding. 

我添加在網絡配置

<httpRuntime maxRequestLength="2097151" executionTimeout="10800" /> 

但我得到相同的錯誤。

而且我想這

sqlCmd.CommandTimeout = 10 

請建議我找到一個解決方案。

+0

服務器沒有響應,這意味着您無法連接到數據庫,請在web.config中找到連接字符串,並嘗試使用SQL Management Studio進行連接,以確保您能夠連接到數據庫 –

+0

連接是否共享?不要重複使用它,甚至不要共享它。而是用'Using'語句在這個方法中創建它。 –

+1

[Timeout expired。可能重複。操作完成之前超時的時間或服務器沒有響應。該聲明已被終止](http://stackoverflow.com/questions/8602395/timeout-expired-the-timeout-period-elapsed-prior-to-completion-of-the-operation) –

回答

0

檢查您的連接是否保持打開狀態並且未處理,因爲這會導致連接池耗盡。如果正確處理連接,則問題將得到解決。

另請檢查您的數據庫統計/查詢計劃是否正確。如果沒有,清除它使用

exec sp_updatestats 

此外,設置commandTimeOut將有所幫助。

0

ExecutionTimeout web.config中:指定的,一個HTTP請求被允許執行

的CommandTimeout的最大數量:指定一個SQL命令被允許的的最大數目執行

嘗試將CommandTimeout設置爲更高的值。默認爲

相關問題