錯誤訊息
************** Exception Text **************
System.Exception: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
原本使用的SQL連線方式如下
Dim Ds As New DataSet
Conn = New SqlConnection(connStr)
Dim records As New List(Of GUIDO)
Dim SqlTxt As String = ""
SqlTxt += " SELECT * "
SqlTxt += " FROM TESTTABLE "
Dim Cmmd As New SqlCommand(SqlTxt, Conn)
Conn.Open()
Dim Da As New SqlDataAdapter(Cmmd)
Da.Fill(Ds)
後來發現Timeout 的原因為預設30秒,剛好這一段SQL 真的屬於比較複雜,所以我就針對這一段SQL加長timeout的預設值到120
就快速解決問題了
Dim Ds As New DataSet
Conn = New SqlConnection(connStr)
Dim records As New List(Of GUIDO)
Dim SqlTxt As String = ""
SqlTxt += " SELECT * "
SqlTxt += " FROM TESTTABLE "
Dim Cmmd As New SqlCommand(SqlTxt, Conn)
Conn.Open()
Dim Da As New SqlDataAdapter(Cmmd)Da.SelectCommand.CommandTimeout = 120Da.Fill(Ds)-後續追蹤-發現DB 因為最近都沒有執行rebulid index ,所以開始造成查詢緩慢的現象緊急先將幾個重要的table 執行rebulid後隔天狀況有改善了,不過最好還是在每天備份的時候順便排程執行rebulid index 會比較好後續再來分享立即rebulid 的方式 跟 排程rebulid