I think most people are writing ASP Program You have encountered similar error messages:
Error number->-2147467259
Error Source-> Microsoft ole db provider for ODBC drivers
Error desc-> [Microsoft] [ODBC driver manager] data source name not found and no default driver
In terms of time, this error message is not very useful to us, or the error message is not very friendly. Let's look at it in another way.
<%
Option explicit
On Error resume next
Dim Conn
Set conn = server. Createobject ("ADODB. Connection ")
'The DSN does not actually exist, so an error message is returned.
Conn. Open "foo"
If err. Number <> 0 then
Err. Clear
Err. Raise vbobjecterror 7 ,_
"Etest. asp", "connection open method failed"
End if
If err. Number <> 0 then
Response. Write ("error on line->" & err. Number-vbobjecterror)
Response. Write ("<br> error source->" & err. Source)
Response. Write ("<br> error desc->" & err. description)
Err. Clear
End if
%>
In this way, we have defined our own error information. If you are interested, you can try it.
The output result of this error message is as follows:
Error on line-> 7
Error Source-> Etest. asp
Error desc-> connection open method failed
This seems a lot more comfortable, and I think it is always better than the original one.
Note that the error number cannot be repeated with the error number defined by the system. Therefore, a constant is added here.