2016-01-24 48 views
0

我在查詢時正在查找特定數據庫錯誤。如果沒有找到錯誤,那麼我想要使用標準錯誤處理。如果錯誤類型會再次引發錯誤

On Error Resume Next 

db.execute(strSQL) 

If db.Errors.Count > 0 Then 
    If InStr(db.Errors(0).Description, "IX_Code") Then 
     ... 
    Else 
     * rethrow here * 
    End If 
End If 

這可能嗎?

我想...

On Error GoTo 0 

Err.Raise 22, "Big Error", "Hello World!" 

但沒有任何反應。

回答

0

我加入這個代碼,我發現here ...

For Each errLoop In db.Errors 

     strError = "Error #" & errLoop.Number & "<br>" & _ 
      " " & errLoop.Description & "<br>" & _ 
      " (Source: " & errLoop.Source & ")" & "<br>" & _ 
      " (SQL State: " & errLoop.SQLState & ")" & "<br>" & _ 
      " (NativeError: " & errLoop.NativeError & ")" & "<br>" 

     Response.Clear 
     Response.Write("<p>" & strError & "</p>") 
     Response.End 

    Next