经过自己的钻研,这个问题已经解决。 我使用的程序如下:
<%
on error resume next
dim conn
Set conn=Server.CreateObject("ADODB.Connection")
conn.connectionstring="dsn=register" '-------register为数据源名称-------
conn.open
set conn=nothing
'-------以下是监视数据库连接状况的代码---------
if conn.state=1 then
response.write "<font color=#ff0000 size=+2 face=黑体>"&"连接数据库成功!"&"</font>"&"<br>" '试验结果为连接成功
else
response.write "<font color=#000000 size=+2 face=宋体>"&"连接数据库失败..."&"</font>"&"<br>"
end if
for i=1 to conn.errors.count-1
cause=conn.errors(i).description
idnum=conn.errors(i).number
source=conn.errors(i).source
response.write "错误数量:"&i &"<br>"
response.write "错误代号:"&idnum&"<br>"
response.write "错误来源:"&source&"<br>"
response.write "错误描述:"&cause&"<br>"
response.write "<hr>"
next
conn.close
set conn=nothing
%>
<%
on error resume next
dim conn
Set conn=Server.CreateObject("ADODB.Connection")
conn.connectionstring="dsn=register" '-------register为数据源名称-------
conn.open
set conn=nothing
'-------以下是监视数据库连接状况的代码---------
if conn.state=1 then
response.write "<font color=#ff0000 size=+2 face=黑体>"&"连接数据库成功!"&"</font>"&"<br>" '试验结果为连接成功
else
response.write "<font color=#000000 size=+2 face=宋体>"&"连接数据库失败..."&"</font>"&"<br>"
end if
for i=1 to conn.errors.count-1
cause=conn.errors(i).description
idnum=conn.errors(i).number
source=conn.errors(i).source
response.write "错误数量:"&i &"<br>"
response.write "错误代号:"&idnum&"<br>"
response.write "错误来源:"&source&"<br>"
response.write "错误描述:"&cause&"<br>"
response.write "<hr>"
next
conn.close
set conn=nothing
%>