
以下是引用片段: Microsoft OLE DB Provider for ODBC Drivers error 80004005 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified /test.asp, line 60 |
以下是引用片段: <% '設置buffer為True Response.Buffer = True '開始錯誤處理 On Error Resume Next %> <% '錯誤處理 If Err.Number <> 0 Then '清除頁面 Response.Clear '顯示錯誤信息給用戶 %> <HTML> <HEAD> <TITLE></TITLE> </HEAD> <BODY BGCOLOR="#C0C0C0"> <FONT FACE="ARIAL">An error occurred in the execution of this ASP page<BR> Please report the following information to the support desk<P> <B>Page Error Object</B><BR> 錯誤 Number: <%= Err.Number %><BR> 錯誤信息: <%= Err.Description %><BR> 出錯文件: <%= Err.Source %><BR> 出錯行: <%= Err.Line %><BR> </FONT> </BODY> </HTML> <%End If%> |
以下是引用片段: If Err.Number = 0 And objConnection.Errors.Count = 0 Then '這里才能執行語句,因為沒有錯誤 Set rstResults = dbData.Execute(txtSql) End If 更多高級的處理辦法 當一個錯誤發生時,你們也可以顯示更多的錯誤信息。下面是同時處理數據庫和頁面錯誤的例子,有了它我們一下就能發現我們程序中的所有錯誤。 <% If Err.Number <> 0 Then Response.Clear Select Case Err.Number Case 8 '指定錯誤的Number '在這里處理自定義錯誤 Case Else '一般錯誤 If IsObject(objConnection) Then If objConnection.Errors.Count > 0 Then %> <B>Database Connection Object</B> <% For intLoop = 0 To objConnection.Errors.Count - 1 %> Error No: <%= objConnection.Errors(intLoop).Number %><BR> Description: <%= objConnection.Errors(intLoop).Description %><BR> Source: <%= objConnection.Errors(intLoop).Source %><BR> SQLState: <%= objConnection.Errors(intLoop).SQLState %><BR> NativeError: <%= objConnection.Errors(intLoop).NativeError %><P> <% Next End If End If If Err.Number <> 0 Then %> <B>Page Error Object</B><BR> Error Number <%= Err.Number %><BR> Error Description <%= Err.Description %><BR> Source <%= Err.Source %><BR> LineNumber <%= Err.Line %><P> <% End If End Select End If %> |
以下是引用片段: If Err.Number = 0 And objConnection.Errors.Count = 0 Then Response.Clear Response.Redirect URL Here End If |
您發布的評論即表示同意遵守以下條款:
一、不得利用本站危害國家安全、泄露國家秘密,不得侵犯國家、社會、集體和公民的合法權益;
二、不得發布國家法律、法規明令禁止的內容;互相尊重,對自己在本站的言論和行為負責;
三、本站對您所發布內容擁有處置權。