I have created a custom error handling .asp page that displays the
information from the infocollected in the ASPError object. However, the
concern is that when a database connection error occurs how will that info
be collected. I wanted to use the same .asp page to collect this
information but needed some direction as to how that can be accomplished.
I am assuming that ADO connection errors are not collected in the same
ASPError object(?). Any help would be appreciated. Here is the code that
I am using which I was able to get off the msdn site to display the info
from the ASPError object.
<%@ Language=VBScript %>
<%
Option Explicit
'===== Modification History =====
'HDT#: Name: Date: Description:
Dim objUser, objError, rs
Dim strU, strSQLStatement, strTemp, strtoday, strusername
Dim strHTMLMsg, errLoop, errflag, Quickrs, Center_Name
Dim blnRecordCountOK, blnNoRecordReturned, blnTooManyRecordsReturned,
blnWhere, blnAllFieldsBlank, blnErrorWritten
Dim intCounter, intRecordsReturned, intNbrOfRtns, iCounter, intPageNbr,
intRecCount, intTtlPages, intStartRec, intUserid
Dim cmdADOCommand, prmADOParameter, strParmName
Set objUser = Server.CreateObject("PropertyStore.ASPVars")
Set objError = Server.GetLastError()
strU = objUser.GetCurrentSessionID
strusername = objUser.username
strtoday = Now()
If Not objUser.LoggedIn Then Response.Redirect "/login.asp?u=" & strU &
"&r=" & Request.ServerVariables("URL")
If Not objUser.HasAccess Then Response.Redirect "/show_access.asp?u=" &
strU
strSQLStatement = "Get_Quicklinks " & objuser.userid
set Quickrs = objuser.getrecordset(strSQLStatement)
intUserid = objUser.userid
'***** Set Boolean variables for blank fields. *****
iCounter = 0
blnWhere = False
blnAllFieldsBlank = False
'***** Include the db_access page. *****
%>
<!--#INCLUDE VIRTUAL="/db_access.asp"-->
<%
'If objError <> "" Then
'***** Input SQL parameters to insert info into ERROR_LOG table from an
error in the ASPError object. *****
' Set cmdADOCommand = Server.CreateObject("ADODB.Command")
' Set prmADOParameter = Server.CreateObject("ADODB.Command")
'
' Set cmdADOCommand.ActiveConnection = conCareGate
' cmdADOCommand.CommandType = adCmdStoredProc
'
'***** Now run the SP to insert into ERROR_LOG table. *****
' strParmName = "hcin_user_id"
' Set prmADOParameter = cmdADOCommand.CreateParameter(strParmName,
adInteger, adParamInput)
' cmdADOCommand.Parameters.Append prmADOParameter
' cmdADOCommand.Parameters(strParmName).Value = intUserid
'
' strParmName = "error_type"
' Set prmADOParameter = cmdADOCommand.CreateParameter(strParmName,
adVarChar, adParamInput, 50)
' cmdADOCommand.Parameters.Append prmADOParameter
' cmdADOCommand.Parameters(strParmName).Value =
'
' strParmName = "error_code"
' Set prmADOParameter =
cmdADOCommand.CreateParameter(strParmName,adVarChar, adParamInput, 50)
' cmdADOCommand.Parameters.Append prmADOParameter
' cmdADOCommand.Parameters(strParmName).Value = strErrASPCode
'
' strParmName = "error_description"
' Set prmADOParameter = cmdADOCommand.CreateParameter(strParmName,
adVarChar, adParamInput, 100)
' cmdADOCommand.Parameters.Append prmADOParameter
' cmdADOCommand.Parameters(strParmName).Value =
'
' strParmName = "error_on_web_page"
' Set prmADOParameter = cmdADOCommand.CreateParameter(strParmName,
adVarChar,adParamInput, 255)
' cmdADOCommand.Parameters.Append prmADOParameter
' cmdADOCommand.Parameters(strParmName).Value =
'
' strParmName = "created_date"
' Set prmADOParameter = cmdADOCommand.CreateParameter(strParmName,
adDBTimeStamp, adParamInput, 11, 135)
' cmdADOCommand.Parameters.Append prmADOParameter
' cmdADOCommand.Parameters(strParmName).Value = strtoday
'
' strSQLStatement = "insert_error_log"
' cmdADOCommand.CommandText = strSQLStatement
' cmdADOCommand.Execute
'
'***** Clean up parameters. *****
'
'End If
%>
<html>
<head>
<title>Page Error</title>
<meta name="generator" content="microsoft visual studio 6.0">
</head>
<body bgcolor="#ffffff">
<h2 align="center"><font face="arial">Page Error</font></h2>
<p align="center"><font face="arial" size="2">An error occurred processing the page
you requested.<br>
Please see the details below for more information.</font></p>
<div align="center"><center>
<table><font face="arial" size="2">
<% If Len(CStr(objError.ASPCode)) > 0 Then %>
<tr>
<th nowrap align="left" valign="top">IIS Error Number</th>
<td align="left" valign="top"><%=objError.ASPCode%></td>
</tr>
<% End If %>
<% If Len(CStr(objError.Number)) > 0 Then %>
<tr>
<th nowrap align="left" valign="top">COM Error Number</th>
<td align="left" valign="top"><%=objError.Number%>
<%=" (0x" & Hex(objError.Number) & ")"%></td>
</tr>
<% End If %>
<% If Len(CStr(objError.Source)) > 0 Then %>
<tr>
<th nowrap align="left" valign="top">Error Source</th>
<td align="left" valign="top"><%=objError.Source%></td>
</tr>
<% End If %>
<% If Len(CStr(objError.Category)) > 0 Then %>
<tr>
<th nowrap align="left" valign="top">Error Category</th>
<td align="left" valign="top"><%=objError.Category%></td>
</tr>
<% End If %>
<% If Len(CStr(objError.File)) > 0 Then %>
<tr>
<th nowrap align="left" valign="top">File Name</th>
<td align="left" valign="top"><%=objError.File%></td>
</tr>
<% End If %>
<% If Len(CStr(objError.Line)) > 0 Then %>
<tr>
<th nowrap align="left" valign="top">Line Number</th>
<td align="left" valign="top"><%=objError.Line%></td>
</tr>
<% End If %>
<% If Len(CStr(objError.Column)) > 0 Then %>
<tr>
<th nowrap align="left" valign="top">Column Number</th>
<td align="left" valign="top"><%=objError.Column%></td>
</tr>
<% End If %>
<% If Len(CStr(objError.Description)) > 0 Then %>
<tr>
<th nowrap align="left" valign="top">Brief Description</th>
<td align="left" valign="top"><%=objError.Description%></td>
</tr>
<% End If %>
<% If Len(CStr(objError.ASPDescription)) > 0 Then %>
<tr>
<th nowrap align="left" valign="top">Full Description</th>
<td align="left" valign="top"><%=objError.ASPDescription%></td>
</tr>
<% End If %>
<tr>
<td align="center"
</font></table>
</center></div>
</body>
</html>
---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]