Results 1 to 4 of 4

Thread: Help

  1. #1

    Thread Starter
    Lively Member cody's Avatar
    Join Date
    Jan 2003
    Posts
    126

    Exclamation Help

    My problem is that i am trying to check in the DB to see if certain values have been already been entered(For a Registration Page):

    Heres my code:

    Set objRS = Server.CreateObject("ADODB.Recordset")

    SQL= "SELECT Username,AccCode,EmailAddress FROM tblUsers"
    Set objRS =conn.Execute (SQL)

    strUsername = Request.Form("x_Username")
    strAccCode = Request.Form("x_AccCode")
    strEmail = Request.Form("x_EmailAddress")

    Do While Not objRs.EOF
    if objRS("Username")=strUsername Then
    Response.redirect "exists.htm"
    Elseif objRS("AccCode")=strAccCode then
    Response.redirect "exists.htm"
    Elseif objRS("EmailAddress")=strEmail then
    Response.redirect "exists.htm"
    End if
    objRS.MoveNext
    Loop

    it checks the Username and Email no porblem and redirects the user to exists.htm if the record exists, but when it comes to Third one (AccCode) it just keeps on inserting a record even though there is a identical record in the database

    Please can someone help, ive tried everything

  2. #2
    Addicted Member
    Join Date
    Aug 2002
    Location
    England
    Posts
    165
    Umm.... I don't see in that code where it tells it to insert...
    _____

    Hehehe

  3. #3
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057

    Please use discriptive subjects.

    Try casting them both as strings "cstr(variable)" or integers "cint(variable)" or check to make sure there is no spaces that are causing them to not match up.
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  4. #4
    Frenzied Member andreys's Avatar
    Join Date
    Sep 2002
    Location
    Los Angeles
    Posts
    1,615
    if your code is alpha-numeric use UCase and CStr to make them in same format:

    Elseif UCase(CStr(objRS("AccCode")))=UCase(CStr(strAccCode)))then

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width