Results 1 to 8 of 8

Thread: If statements

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2001
    Location
    Alberton, Gauteng, South-Africa
    Posts
    48

    Angry

    Hey guy's

    I'm trying to compare a string sent by the User to data stored in the DB. Now when I send the results and stuff over I get the No Match found Statement that's in the Else statement .. and I know for a fact that the strings I'm comapring are in the Tables.

    Now if i send strings over that doesn't exist in the table I get a Exeption Error Occured on Line 26 .. line 26 is the IF ***** Then line.

    Here's my code

    ***************

    Set rsResults = conn.Execute("SELECT Comp_PWD FROM Company WHERE Comp_UID = '" & UserName & "'")

    if rsResults("Comp_PWD") = Request.Querystring("sPWD") Then
    Response.Write "UserID and Password Matches"
    else
    Response.Write "No matching Results"
    end IF

    *****************

    Thanks in advance
    ;-)
    Jaco
    South-Africa

  2. #2
    Guest
    Try changing rsResults("Comp_PWD") to read rsResults.fields("Comp_PWD")

  3. #3
    Guest

    Cool

    hi....try this

    Set rsResults = conn.Execute("SELECT Comp_PWD FROM Company WHERE Comp_UID = '" & UserName & "'")

    if Not rsResults.EOF then

    if rsResults("Comp_PWD") = Request.Querystring("sPWD") Then
    Response.Write "UserID and Password Matches"
    rsResults.MoveNext
    end IF

    else
    Response.Write "No matching Results"
    end if


    Regards,
    Mac

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2001
    Location
    Alberton, Gauteng, South-Africa
    Posts
    48

    Unhappy No Joy!

    Hey Mad worm .. yours gave the same results.

    Mac.L Your atleast changed the results to .. Nothing .. seriously .. it didn't return even the No Matches found.

    Here's my Complete code:

    ************

    Dim conn
    Dim rsResults
    Dim UserName
    Dim PWD
    Dim aConnect

    UserName = Request.Querystring("sUID")
    PWD = Request.Querystring("sPWD")
    aConnect = "Provider=SQLOLEDB.1;Persist Security Info=False;Data Source=DEV-SVR;Initial Catalog=Alchemy;User ID=Guest;Password=;ConnectionTimeout=10;"

    Set conn = Server.CreateObject("ADODB.Connection")
    Set rsResults = Server.CreateObject ("ADODB.Recordset")
    conn.Mode = abModeReadWrite
    conn.ConnectionString = aConnect
    conn.open

    Set rsResults = conn.Execute("SELECT Comp_PWD FROM Company WHERE Comp_UID = '" & UserName & "'")

    if rsResults.fields("Comp_PWD") = Request.Querystring("sPWD") Then
    Response.Write "UserID and Password Matches"
    else
    Response.Write "No matching Results"
    end IF

    'L Set rsResults = conn.Execute("SELECT Comp_PWD FROM Company WHERE Comp_UID = '" & UserName & "'")

    'L if Not rsResults.EOF then
    'L if rsResults("Comp_PWD") = Request.Querystring("sPWD") Then
    'L Response.Write "UserID and Password Matches"
    'L rsResults.MoveNext
    'L end if
    'L else
    'L Response.Write "No matching Results"
    'L end if

    rsResults.Close
    conn.Close


    *****
    Thanks for your help!
    ;-)
    Jaco
    South-Africa

  5. #5
    Guest

    Cool

    Hi...

    Set rsResults = conn.Execute("SELECT Comp_PWD FROM Company WHERE Comp_UID = '" & UserName & "'")

    You SQL statement seem just select one field,

    try this,

    Set rsResults = conn.Execute("SELECT * FROM Company WHERE Comp_UID = '" & UserName & "'")



    Regards,
    Mac

  6. #6

    Thread Starter
    Member
    Join Date
    Jan 2001
    Location
    Alberton, Gauteng, South-Africa
    Posts
    48

    Unhappy Nope ...

    Hey there Mac L. thanks for your help!

    I tried what you said but it didn't work .. then i thought baybee the Recordset was empty .. So I made it to write:
    **
    Response.Write rsResults("Comp_PWD") & "<br>"
    Response.Write Request.Querystring("sPWD") & "<br>"
    **

    I get the same result .. the Comp_PWD and the Querystring value match .. so it's supposed to work ... I seems to me that the fault is somewhere in the If statement .. the select statement with the Wildcard * is usefull because I need the check the Username as well as the PWD.

    I'm going to try some diffrent flavours of If Statements .. maybe it will work out some where .. but your help will b apreciated!

    Cheers
    and Thanks
    ;-)
    Jaco
    South-Africa

  7. #7

    Thread Starter
    Member
    Join Date
    Jan 2001
    Location
    Alberton, Gauteng, South-Africa
    Posts
    48

    Unhappy Still broken ...

    Ok I'm desparate!

    Here's the code:
    **************

    <%
    Dim conn 'Connection
    Dim rsResults 'Record Set
    Dim aConnect 'Connection String
    dim i 'Testing

    i = 2 'Testing Value

    aConnect = "Provider=SQLOLEDB.1;Persist Security Info=False;Data Source=DEV-SVR;Initial Catalog=Alchemy;User ID=Guest;Password=;ConnectionTimeout=10;"

    Set conn = Server.CreateObject("ADODB.Connection")
    Set rsResults = Server.CreateObject ("ADODB.Recordset")
    conn.Mode = abModeReadWrite
    conn.ConnectionString = aConnect
    conn.open

    Set rsResults = conn.Execute("SELECT * FROM Company WHERE Comp_UID = '" & Request.Querystring("sUID") & "'")

    ' get value of Record set
    Response.Write "RecordSet <br>"
    Response.Write rsResults("Comp_PWD") & "<br>"
    ' get value of Querystring
    Response.Write "Querystring <br>"
    Response.Write Request.Querystring("sPWD") & "<br>"

    Response.write "<br>"
    'Test the values against each other
    if rsResults("Comp_PWD") = Request.Querystring("sPWD") then
    Response.write "Test Suceeded"
    else
    Response.write "try Again<br>"
    end if

    Response.write "<br>"
    ' Test If Statement

    if i = 2 then
    Response.Write "Test if Worked"
    Else
    Response.Write "Test if Broken"
    End If


    rsResults.Close
    conn.Close
    %>

    *************

    Here's the results

    *************

    RecordSet
    demo
    Querystring
    demo

    try Again

    Test if Worked

    *************

    As you can see from the above the Recordset and the Querystring matches. I tried diffrent flavours, setting the Quearystring equal to anothe value but still no joy .. what am I doing wrong?

    HELP!!
    ;-)
    Jaco
    South-Africa

  8. #8
    Guest

    Cool

    Hi .... try this again ...

    Dim conn 'Connection
    Dim rsResults 'Record Set
    Dim aConnect 'Connection String
    dim i 'Testing
    i = False

    aConnect = "Provider=SQLOLEDB.1;Persist Security Info=False;Data Source=DEV-SVR;Initial Catalog=Alchemy;User ID=Guest;Password=;ConnectionTimeout=10;"

    Set conn = Server.CreateObject("ADODB.Connection")
    Set rsResults = Server.CreateObject ("ADODB.Recordset")
    conn.Mode = abModeReadWrite
    conn.ConnectionString = aConnect
    conn.open

    Set rsResults = conn.Execute("SELECT * FROM Company WHERE Comp_UID = '" & Request.Querystring("sUID") & "'")

    Do While Not rsResults.EOF
    if rsResults("Comp_PWD") = Request.Querystring ("sPWD") then
    i = True
    end if
    rsResult.Movenext
    Loop

    if i = True then
    Response.write "Record Found !"
    else
    response.write "No record found !"
    end if

    rsResults.Close
    conn.Close

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