Checking for Existence in RS

Discussion in 'ASP General' started by Keith, Jan 13, 2005.

  1. Keith

    Keith Guest

    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
     
    Keith, Jan 13, 2005
    #1
    1. Advertising

  2. Keith

    Steven Burn Guest

    '// 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!

    "Keith" <@.> wrote in message news:ucWD$cW#...
    > 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
    >
    >
     
    Steven Burn, Jan 13, 2005
    #2
    1. Advertising

  3. Keith wrote:
    > 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

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Jan 13, 2005
    #3
  4. Keith

    Keith Guest

    Thanks both

    I have sorted this now
     
    Keith, Jan 13, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Adam
    Replies:
    2
    Views:
    3,965
    Steve C. Orr, MCSD
    Aug 14, 2003
  2. Bob Roberts
    Replies:
    3
    Views:
    346
    Terry Reedy
    Oct 12, 2003
  3. Jim Hunter
    Replies:
    3
    Views:
    612
    Jim Hunter
    Mar 6, 2005
  4. AndyB
    Replies:
    1
    Views:
    293
    Paul Hankin
    Sep 28, 2007
  5. Andy B.
    Replies:
    1
    Views:
    350
    Alexey Smirnov
    Feb 6, 2009
Loading...

Share This Page