By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,664 Members | 1,970 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,664 IT Pros & Developers. It's quick & easy.

Avoid On Error Resume Next?

P: n/a
Is there a way to avoid On Error Resume Next for:

cnn.Open strCon
SQL = "EXEC Customer @txtEmail='" & email_address & "'"
set rs = cnn.execute(SQL)

'On error resume next
rs("email_address")

'// This record does not exist thus throwing up an error. I could use On
Error to resume and then do this
'// If rs.eof or rs.bof
'//

.....But I hate this convention as I find debugging a problem. Is there a
better way?

Thanks
Jason
Jul 19 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
cnn.Open strCon
SQL = "EXEC Customer @txtEmail='" & email_address & "'"
set rs = cnn.execute(SQL)

If rs.EOF Then
'''empty
Else
sEmailAddress = rs.fields.item(0).value
End If
I believe that should work just fine. What part don't you like, the
checking for eof? Will this ever be true anyway? That would depend on your
stored procedure. Like, you could make it so that there is always a result
returned.

Ray at work

"jason" <ja***@catamaranco.com> wrote in message
news:uO*************@TK2MSFTNGP10.phx.gbl...
Is there a way to avoid On Error Resume Next for:

cnn.Open strCon
SQL = "EXEC Customer @txtEmail='" & email_address & "'"
set rs = cnn.execute(SQL)

'On error resume next
rs("email_address")

'// This record does not exist thus throwing up an error. I could use On
Error to resume and then do this
'// If rs.eof or rs.bof
'//

....But I hate this convention as I find debugging a problem. Is there a
better way?

Thanks
Jason

Jul 19 '05 #2

P: n/a
You don't like "if rs.EOF"? That's the standard way to deal with
possibly empty recordsets. What about it causes debugging problems for
you? What information do you need that you're not getting from
something like:

set rs = cnn.execute(SQL)
response.write "Executed SQL: " & SQL & "<br>"
if rs.EOF then
response.write "Sorry, no email address found."
else
response.write "Found email address " & rs("email_address")
end if

"jason" <ja***@catamaranco.com> wrote in message
news:uO*************@TK2MSFTNGP10.phx.gbl...
Is there a way to avoid On Error Resume Next for:
cnn.Open strCon
SQL = "EXEC Customer @txtEmail='" & email_address & "'"
set rs = cnn.execute(SQL)
'On error resume next
rs("email_address")
'// This record does not exist thus throwing up an error. I could use On Error to resume and then do this
'// If rs.eof or rs.bof
'//
....But I hate this convention as I find debugging a problem. Is there a better way?
Thanks
Jason

Jul 19 '05 #3

P: n/a
But, the problem is that when there is no record matching the emial I pick
up an .EOF or BOF errror, thus I cannot I do a If rs.eof to trap the error
unless I use On Error Resume Next:

set cnn = Server.CreateObject("ADODB.Connection")
strCon = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
Server.MapPath("../database/listings.mdb") '//This one is for Access
2000/2002

cnn.Open strCon
SQL = "EXEC Customer @txtEmail='" & email_address & "'"
set rs = cnn.execute(SQL)

'On error resume next
email_address=rs("email_address") '//*** ERROR OCCURS AT THIS POINT, BUT IT
WILL NOT ALLOW
'// ME TO GO TO THE Recordset eof or bof stage UNLESS I place On Error
Resume Next before the variable assignment.

If rs.eof or rs.bof then

etc

End If

I must be missing something here. My query is programmed to accept NULL
values (=ALL RECORDS) or a specific email address for the paramater.

What am I doing wrong here.

- Jason

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:O8**************@tk2msftngp13.phx.gbl...
cnn.Open strCon
SQL = "EXEC Customer @txtEmail='" & email_address & "'"
set rs = cnn.execute(SQL)

If rs.EOF Then
'''empty
Else
sEmailAddress = rs.fields.item(0).value
End If
I believe that should work just fine. What part don't you like, the
checking for eof? Will this ever be true anyway? That would depend on your stored procedure. Like, you could make it so that there is always a result returned.

Ray at work

"jason" <ja***@catamaranco.com> wrote in message
news:uO*************@TK2MSFTNGP10.phx.gbl...
Is there a way to avoid On Error Resume Next for:

cnn.Open strCon
SQL = "EXEC Customer @txtEmail='" & email_address & "'"
set rs = cnn.execute(SQL)

'On error resume next
rs("email_address")

'// This record does not exist thus throwing up an error. I could use On
Error to resume and then do this
'// If rs.eof or rs.bof
'//

....But I hate this convention as I find debugging a problem. Is there a better way?

Thanks
Jason


Jul 19 '05 #4

P: n/a
This is why you check for rs.EOF BEFORE you try to call a value from the RS,
as I did in the code I provided.

Ray at work

"jason" <ja***@catamaranco.com> wrote in message
news:Ow**************@TK2MSFTNGP10.phx.gbl...
But, the problem is that when there is no record matching the emial I pick
up an .EOF or BOF errror, thus I cannot I do a If rs.eof to trap the error
unless I use On Error Resume Next:

set cnn = Server.CreateObject("ADODB.Connection")
strCon = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
Server.MapPath("../database/listings.mdb") '//This one is for Access
2000/2002

cnn.Open strCon
SQL = "EXEC Customer @txtEmail='" & email_address & "'"
set rs = cnn.execute(SQL)

'On error resume next
email_address=rs("email_address") '//*** ERROR OCCURS AT THIS POINT, BUT IT WILL NOT ALLOW
'// ME TO GO TO THE Recordset eof or bof stage UNLESS I place On Error
Resume Next before the variable assignment.

If rs.eof or rs.bof then

etc

End If

I must be missing something here. My query is programmed to accept NULL
values (=ALL RECORDS) or a specific email address for the paramater.

What am I doing wrong here.

- Jason

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:O8**************@tk2msftngp13.phx.gbl...
cnn.Open strCon
SQL = "EXEC Customer @txtEmail='" & email_address & "'"
set rs = cnn.execute(SQL)

If rs.EOF Then
'''empty
Else
sEmailAddress = rs.fields.item(0).value
End If
I believe that should work just fine. What part don't you like, the
checking for eof? Will this ever be true anyway? That would depend on your
stored procedure. Like, you could make it so that there is always a

result
returned.

Ray at work

"jason" <ja***@catamaranco.com> wrote in message
news:uO*************@TK2MSFTNGP10.phx.gbl...
Is there a way to avoid On Error Resume Next for:

cnn.Open strCon
SQL = "EXEC Customer @txtEmail='" & email_address & "'"
set rs = cnn.execute(SQL)

'On error resume next
rs("email_address")

'// This record does not exist thus throwing up an error. I could use On Error to resume and then do this
'// If rs.eof or rs.bof
'//

....But I hate this convention as I find debugging a problem. Is
there a better way?

Thanks
Jason



Jul 19 '05 #5

P: n/a
Sorry Ray - how stupid of me! I was trying to extract the email knowing it
did not exist - thus making my .EOF check invalid. Sorry for wasting your
time!
- Jason

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:OQ**************@TK2MSFTNGP12.phx.gbl...
This is why you check for rs.EOF BEFORE you try to call a value from the RS, as I did in the code I provided.

Ray at work

"jason" <ja***@catamaranco.com> wrote in message
news:Ow**************@TK2MSFTNGP10.phx.gbl...
But, the problem is that when there is no record matching the emial I pick
up an .EOF or BOF errror, thus I cannot I do a If rs.eof to trap the error unless I use On Error Resume Next:

set cnn = Server.CreateObject("ADODB.Connection")
strCon = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
Server.MapPath("../database/listings.mdb") '//This one is for Access
2000/2002

cnn.Open strCon
SQL = "EXEC Customer @txtEmail='" & email_address & "'"
set rs = cnn.execute(SQL)

'On error resume next
email_address=rs("email_address") '//*** ERROR OCCURS AT THIS POINT, BUT IT
WILL NOT ALLOW
'// ME TO GO TO THE Recordset eof or bof stage UNLESS I place On Error
Resume Next before the variable assignment.

If rs.eof or rs.bof then

etc

End If

I must be missing something here. My query is programmed to accept NULL
values (=ALL RECORDS) or a specific email address for the paramater.

What am I doing wrong here.

- Jason

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:O8**************@tk2msftngp13.phx.gbl...
cnn.Open strCon
SQL = "EXEC Customer @txtEmail='" & email_address & "'"
set rs = cnn.execute(SQL)

If rs.EOF Then
'''empty
Else
sEmailAddress = rs.fields.item(0).value
End If
I believe that should work just fine. What part don't you like, the
checking for eof? Will this ever be true anyway? That would depend
on your
stored procedure. Like, you could make it so that there is always a

result
returned.

Ray at work

"jason" <ja***@catamaranco.com> wrote in message
news:uO*************@TK2MSFTNGP10.phx.gbl...
> Is there a way to avoid On Error Resume Next for:
>
> cnn.Open strCon
> SQL = "EXEC Customer @txtEmail='" & email_address & "'"
> set rs = cnn.execute(SQL)
>
> 'On error resume next
> rs("email_address")
>
> '// This record does not exist thus throwing up an error. I could

use On > Error to resume and then do this
> '// If rs.eof or rs.bof
> '//
>
> ....But I hate this convention as I find debugging a problem. Is

there
a
> better way?
>
> Thanks
> Jason
>
>



Jul 19 '05 #6

P: n/a
Thanks Ken - I was stupidly trying to pull an email that did not exist thus
making the .EOF check invalid

Cheers
Jason
"Kris Eiben" <ei*********************@yahoo.com> wrote in message
news:Ob**************@TK2MSFTNGP09.phx.gbl...
You don't like "if rs.EOF"? That's the standard way to deal with
possibly empty recordsets. What about it causes debugging problems for
you? What information do you need that you're not getting from
something like:

set rs = cnn.execute(SQL)
response.write "Executed SQL: " & SQL & "<br>"
if rs.EOF then
response.write "Sorry, no email address found."
else
response.write "Found email address " & rs("email_address")
end if

"jason" <ja***@catamaranco.com> wrote in message
news:uO*************@TK2MSFTNGP10.phx.gbl...
Is there a way to avoid On Error Resume Next for:
cnn.Open strCon
SQL = "EXEC Customer @txtEmail='" & email_address & "'"
set rs = cnn.execute(SQL)
'On error resume next
rs("email_address")
'// This record does not exist thus throwing up an error. I could use

On
Error to resume and then do this
'// If rs.eof or rs.bof
'//
....But I hate this convention as I find debugging a problem. Is

there a
better way?
Thanks
Jason


Jul 19 '05 #7

P: n/a
No waste at all!

Ray at home

--
Will trade ASP help for SQL Server help
"jason" <ja***@catamaranco.com> wrote in message
news:On**************@TK2MSFTNGP09.phx.gbl...
Sorry Ray - how stupid of me! I was trying to extract the email knowing it did not exist - thus making my .EOF check invalid. Sorry for wasting your
time!
- Jason

Jul 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.