当前位置:编程学习 > asp >>

如何同时处理数据库和页面错误?

答案:

If Err.Number = 0 And objConnection.Errors.Count = 0 Then
  Response.Clear
   Response.Redirect ?lt;URL Here>?
 End If

    都准备好后,我们来看看程序代码:
 <% 
  If Err.Number <> 0 Then
           Response.Clear
           Select Case Err.Number
    Case 8
' 指定错误号,在这里处理自定义错误

                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%>
     
    错误号: <%= objConnection.Errors(intLoop).Number %><BR>
    错误描述: <%= objConnection.Errors(intLoop).Description %><BR>
    错误源: <%= objConnection.Errors(intLoop).Source %><BR>
    SQL状态: <%= objConnection.Errors(intLoop).SQLState %><BR>
    本地错误: <%= objConnection.Errors(intLoop).NativeError %><P>
  <%
Next
  End If
   End If
    If Err.Number <> 0 Then
  %>
   <B>Page Error Object</B><BR>
    错误号 <%= Err.Number %><BR>
    错误描述 <%= Err.Description %><BR>  
    错误源<%= Err.Source %><BR>
    错误行<%= Err.Line %><P>
 
 <%
End If
  End Select
  End If
 %>

上一个:如何随机显示网站链接?
下一个:如何使用表单发送电子邮件?

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,