Checking for Existence in RS

K

Keith

I have a simple form where a user enters their email address, which then
passed them to a 2nd page where the email address entered is used to filter
a recordset.

How can I set up an IF statement so it checkes every record in the
recordset, and if the email address entered does not match any record
redirect to another page?

Thanks
 
S

Steven Burn

'// Code to connect to your database
'//.........
Dim blnIsPresent
blnIsPresent = False
Do While Not objRst.EOF
If lcase(objRst("fldE_Mail"))=lcase(strStringToMatch) Then
'// E-mail is present
blnIsPresent = True:Exit Do
End If
Loop
'// Code to close your DB connection

If blnIsPresent = False Then Response.Redirect "does_not_exist.asp"

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
 
B

Bob Barrows [MVP]

Keith said:
I have a simple form where a user enters their email address, which
then passed them to a 2nd page where the email address entered is
used to filter a recordset.

How can I set up an IF statement so it checkes every record in the
recordset, and if the email address entered does not match any record
redirect to another page?
Don't loop through a recordset to see if a record exists, that's what a
WHERE clause in a sql statement is for. A recordset loop can be thousands of
time slower than a sql statement with a filter.

I'd like to provide a specific example, but I don't know what database you
are using. Please supply the database type and version whenever you ask a
database-related question. It is almost always relevant.

Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top