Forums
This topic is locked
Error trapping problem with looped regions
Posted 13 May 2005 19:27:02
1
has voted
13 May 2005 19:27:02 adam partridge posted:
i have some error trapping code that works fine on a recordset as long as it is not looped.. however when i use it on a page that has a looped region and duff data is entered it gets stuck in an infinate loop.. any one any ideas help very much appreciatedthe code is :
pastebin.com/283734
Replies
Replied 16 May 2005 13:38:44
16 May 2005 13:38:44 adam partridge replied:
for some reason pastebin has gone .. so here my code :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/website.asp" -->
<%
Dim strErrorMessage
Dim bolErrors
'Initialize variables
strErrorMessage = "" 'The error messages for tech. support
bolErrors = False 'Have we found any errors yet?
'Now our two subs
sub TrapError(strError)
bolErrors = True 'Egad, we've found an error!
strErrorMessage = strErrorMessage & strError & ", "
end sub
'If there are any errors, this function will email tech. support
sub ProcessErrors()
if bolErrors then
'Send the email
Dim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail"
objCDO.To = " "
objCDO.From = " "
objCDO.Subject = "AN ADO ERROR OCCURRED"
objCDO.Body = "At " & Now & " the following errors occurred on " & _
"the page " & Request.ServerVariables("SCRIPT_NAME" & _
": " & _
chr(10) & chr(10) & strErrorMessage
objCDO.Send
Set objCDO = Nothing
'Now, we've got to print out something for the user
Response.Write "There has been a database error. Technical Support " & _
"has already been notified." & _
"Thank you for your patience"
end if
end sub
%>
<% On Error Resume Next %>
<%
Dim rsnews__MMcolparam1
rsnews__MMcolparam1 = "1/1/2001"
If (Request("stdate" <> "" Then
rsnews__MMcolparam1 = Request("stdate"
End If
%>
<%
Dim rsnews__MMcolparam2
rsnews__MMcolparam2 = "6/6/2079"
If (Request("enddate" <> "" Then
rsnews__MMcolparam2 = Request("enddate"
End If
%>
<%
Dim rsnews
Dim rsnews_numRows
Set rsnews = Server.CreateObject("ADODB.Recordset"
If Err.number <> 0 then
TrapError Err.description
End If
rsnews.ActiveConnection = MM_encams_STRING
If Err.number <> 0 then
TrapError Err.description
End If
rsnews.Source = "SELECT intid, dtdateexpires, strnewstitle, dtdate, dtstartdate, strshortdescripiton FROM dbo.tblnews WHERE ISNULL(dtstartdate," & date() & " BETWEEN " + Replace(rsnews__MMcolparam1, "'", "''" + " AND " + Replace(rsnews__MMcolparam2, "'", "''" + " ORDER BY dtdate DESC"
rsnews.CursorType = 0
rsnews.CursorLocation = 2
rsnews.LockType = 1
rsnews.Open()
If Err.number <> 0 then
TrapError Err.description
End If
rsnews_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = 10
Repeat1__index = 0
rsnews_numRows = rsnews_numRows + Repeat1__numRows
%>
<% If Not rsnews.EOF Or Not rsnews.BOF Then %>
<%
While ((Repeat1__numRows <> 0) AND (NOT rsnews.EOF))
%>
<table width="100%%" border="0" cellspacing="0" cellpadding="0">
<tr class="boldtext">
<td width="78%"><a href="../home/newsdetail.asp?nw=<%= (rsnews.Fields.Item("intid".Value)%>"><%=(rsnews.Fields.Item("strnewstitle".Value)%></a></td>
<td width="22%"><div align="right" class="newsbody"><%=(rsnews.Fields.Item("dtdate".Value)%></div></td>
</tr>
<tr>
<td colspan="2" class="newsbody"><%=(rsnews.Fields.Item("strshortdescripiton".Value)%></td>
</tr>
</table>
<hr size="1" noshade="noshade" />
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsnews.MoveNext()
Wend
%>
<% End If ' end Not rsnews.EOF Or NOT rsnews.BOF %>
<%
rsnews.Close()
Set rsnews = Nothing
%>
<%ProcessErrors%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/website.asp" -->
<%
Dim strErrorMessage
Dim bolErrors
'Initialize variables
strErrorMessage = "" 'The error messages for tech. support
bolErrors = False 'Have we found any errors yet?
'Now our two subs
sub TrapError(strError)
bolErrors = True 'Egad, we've found an error!
strErrorMessage = strErrorMessage & strError & ", "
end sub
'If there are any errors, this function will email tech. support
sub ProcessErrors()
if bolErrors then
'Send the email
Dim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail"
objCDO.To = " "
objCDO.From = " "
objCDO.Subject = "AN ADO ERROR OCCURRED"
objCDO.Body = "At " & Now & " the following errors occurred on " & _
"the page " & Request.ServerVariables("SCRIPT_NAME" & _
": " & _
chr(10) & chr(10) & strErrorMessage
objCDO.Send
Set objCDO = Nothing
'Now, we've got to print out something for the user
Response.Write "There has been a database error. Technical Support " & _
"has already been notified." & _
"Thank you for your patience"
end if
end sub
%>
<% On Error Resume Next %>
<%
Dim rsnews__MMcolparam1
rsnews__MMcolparam1 = "1/1/2001"
If (Request("stdate" <> "" Then
rsnews__MMcolparam1 = Request("stdate"
End If
%>
<%
Dim rsnews__MMcolparam2
rsnews__MMcolparam2 = "6/6/2079"
If (Request("enddate" <> "" Then
rsnews__MMcolparam2 = Request("enddate"
End If
%>
<%
Dim rsnews
Dim rsnews_numRows
Set rsnews = Server.CreateObject("ADODB.Recordset"
If Err.number <> 0 then
TrapError Err.description
End If
rsnews.ActiveConnection = MM_encams_STRING
If Err.number <> 0 then
TrapError Err.description
End If
rsnews.Source = "SELECT intid, dtdateexpires, strnewstitle, dtdate, dtstartdate, strshortdescripiton FROM dbo.tblnews WHERE ISNULL(dtstartdate," & date() & " BETWEEN " + Replace(rsnews__MMcolparam1, "'", "''" + " AND " + Replace(rsnews__MMcolparam2, "'", "''" + " ORDER BY dtdate DESC"
rsnews.CursorType = 0
rsnews.CursorLocation = 2
rsnews.LockType = 1
rsnews.Open()
If Err.number <> 0 then
TrapError Err.description
End If
rsnews_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = 10
Repeat1__index = 0
rsnews_numRows = rsnews_numRows + Repeat1__numRows
%>
<% If Not rsnews.EOF Or Not rsnews.BOF Then %>
<%
While ((Repeat1__numRows <> 0) AND (NOT rsnews.EOF))
%>
<table width="100%%" border="0" cellspacing="0" cellpadding="0">
<tr class="boldtext">
<td width="78%"><a href="../home/newsdetail.asp?nw=<%= (rsnews.Fields.Item("intid".Value)%>"><%=(rsnews.Fields.Item("strnewstitle".Value)%></a></td>
<td width="22%"><div align="right" class="newsbody"><%=(rsnews.Fields.Item("dtdate".Value)%></div></td>
</tr>
<tr>
<td colspan="2" class="newsbody"><%=(rsnews.Fields.Item("strshortdescripiton".Value)%></td>
</tr>
</table>
<hr size="1" noshade="noshade" />
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsnews.MoveNext()
Wend
%>
<% End If ' end Not rsnews.EOF Or NOT rsnews.BOF %>
<%
rsnews.Close()
Set rsnews = Nothing
%>
<%ProcessErrors%>