Error I think most people have encountered similar error messages when they write ASP programs:
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
But in time, this error message is not very useful to us, or the wrong message is not very friendly, let us look at the different ways to see.
<%
Option Explicit
On Error Resume Next
Dim Conn
Set Conn = Server.CreateObject ("ADODB. Connection ")
' This DSN does not actually exist, so return the error message
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 define the error message ourselves, interested friends can try
The following is the output of the error message:
Error on line-> 7
Error Source-> etest.asp
Error Desc-> Connection Open method Failed
It looks more comfortable, and I think it's better than the original.
Note that defining the error number cannot be repeated with the system's previously defined error number, so a constant is added here.
:)