ASP程序里涉及到数据库连接的地方,一般都把数据库连接部分放到conn.asp里,在需要的地方include进来,数据库连接一旦出错,程序有可能并不能立即在错误处停止,在连接部分,使用下面的代码,或者结合你自己的程序改装一下,当数据库连接出错,程序会立即停止,并给出提示信息!
err.clear
conn.Open conn_str
if err then
response.Write err.description
response.Write "<h1 style=""margin-top:200px;font-size:30px;font-weight:700;text-align:center;color:red;"" onmouseover=""this.style.font-color=blue;"">★数据库连接错误★</h1>"
err.clear
response.End()
end if