
<% '设置错误处理方式
On Error Resume Next
Set conn=Server.CreateObject("ADODB.Connection")
'设置连接信息，使用一个不存在的数据源
conn.Open "DSN=stu1"
Set errs = conn.Errors
If errs.count=0 then
   Response.Write "数据库连接成功<BR>"
Else
   Response.Write "系统发生"&errs.Count&"个错误<BR><HR>"
   For i=0 To errs.Count-1
       Response.Write "<TABLE border = 0>"       
       Response.Write "<TR><TD>Description属性</TD>"
       Response.Write "<TD>"&errs(i).Description&"</TD></TR>"
       Response.Write "<TR><TD>Mumber属性</TD>"
       Response.Write "<TD>"&errs(i).Number&"</TD></TR>"
       Response.Write "<TR><TD>Source属性</TD>"
       Response.Write "<TD>"&errs(i).source&"</TD></TR>"
       Response.Write "<TR><TD>NativeError属性</TD>"
       Response.Write "<TD>"&errs(i).NativeError&"</TD></TR>"
       Response.Write "<TR><TD>SQLState属性</TD>"
       Response.Write "<TD>"&errs(i).SQLState&"</TD></TR>"
       Response.Write "<TR><TD>HelpContext属性</TD>"
       Response.Write "<TD>"&errs(i).HelpContext&"</TD></TR>"
       Response.Write "<TR><TD>HelpFile属性</TD>"
       Response.Write "<TD>"&errs(i).HelpFile&"</TD></TR>"
       Response.Write "</TABLE><HR>"
   Next
End If  
Set conn=nothing   
%>
