如何捕获错误并保存错误详细的数据库,并重定向到自定义错误页在传统的ASP? [英] how to trap an error and save error detail in database and redirect to custom error page in classic asp?

查看:181
本文介绍了如何捕获错误并保存错误详细的数据库,并重定向到自定义错误页在传统的ASP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何捕获错误并保存错误详细的数据库,并重定向到自定义错误页在传统的ASP?

how to trap an error and save error detail in database and redirect to custom error page in classic asp?

我想,我应该在我的网站的所有页面ASP网页,如果任何错误发生就得到这个错误的细节,它保存到数据库或邮寄到邮件ID和重定向到自定义错误页。
请,如果您有任何想法,请您帮助我。

I want that I should include a asp page in all page of my website and if any error occur it get that error detail, saved it to database or mail it to mail id and redirect to custom error page. Please if you have any idea then please help me.

推荐答案

传统的ASP没有的try / catch。
它还使用VBscript的默认以上的回答是,我猜,C#?
这里是VBScript的ASP为你正在尝试做的:

Classic ASP has no try/catch. It also uses VBscript by default and the answer above is, I'm guessing, C#? Here is VBscript ASP for what you are trying to do:

<%
Set conn = Server.CreateObject("ADODB.Connection") 
SQL_server_string = "Provider=SQLOLEDB; Data Source=myMachine; Initial Catalog=pubs; User ID=sa; Password=pw"
ConnectionString = SQL_server_string
conn.Open ConnectionString

s = "INSERT INTO"
s = s & " tablename "
s = s & "("
s = s & " fieldname1 "
s = s & ",fieldname2 "
s = s & ") "
s = s & "VALUES"
s = s & "( "
s = s & "'" & stringvalue1 & "'"
s = s & ",'" & stringvalue2 & "'"
s = s & ") "

conn.execute(s)
if (err.number<>0) then
m = "error on page ___ line ____<br>"
m = m & "error number: " & err.number & "<br>"
m = m & "error description: " & err.description & "<br>"
m = m 7 "sql: " & s & "<br>"
session("msg") = m
set conn=nothing
response.redirect("error_report.asp")
end if
'got past error checking... do stuff...
%>

这篇关于如何捕获错误并保存错误详细的数据库,并重定向到自定义错误页在传统的ASP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆