ASP login script

Discussion in 'C#' started by solarthur01@hotmail.com, Oct 17, 2007.

  1. #1
    can any of you geniuses help. Im not too familiar with asp. Im trying to create a simple login script but iv tried everything but i keep getting the following error

    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
    [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
    /BegASPNET/login.asp, line 56


    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    heres the code:

    <%
    Response.Expires = -1000 'Makes the browser not cache this page
    Response.Buffer = True 'Buffers the content so our Response.Redirect will work

    Dim Error_Msg

    login = Request.Form("login")
    If login = "logout" Then
    Session("UserLoggedIn") = ""
    ShowLogin
    Else
    If Session("UserLoggedIn") = "true" Then
    AlreadyLoggedIn
    Else
    If login = "true" Then
    CheckLogin
    Else
    ShowLogin
    End If
    End If
    End If

    Sub ShowLogin
    Response.Write(Error_Msg & "<br>")
    %>
    <form name=form1 action=login.asp method=post>
    User Name : <input type=text name=username><br>
    Password : <input type=password name=userpwd><br>
    <input type=hidden name=login value=true>
    <input type=submit value="Login">
    </form>
    >%
    End Sub

    Sub AlreadyLoggedIn
    %>
    You are already logged in.
    Do you want to logout or login as a different user?
    <form name=form2 action=login.asp method=post>
    <input type=submit name=button1 value="Yes">
    <input type=hidden name=login value="logout">
    </form>
    <%
    End Sub

    Sub CheckLogin
    Dim Conn, cStr, sql, RS, username, userpwd
    username = Request.Form("username")
    userpwd = Request.Form("userpwd")
    Set Conn = Server.CreateObject("ADODB.Connection")
    cStr = "DRIVER={Microsoft Access Driver (*.mdb)};"
    cStr = cStr & "DBQ=" & Server.MapPath("guestbook.mdb") & ";"
    Conn.Open(cStr)
    sql = "select username from UserTable where username = '" & LCase(username) & "'"
    sql = sql & " and userpwd = '" & LCase(userpwd) & "'"
    Set RS = Conn.Execute(sql)
    If RS.BOF And RS.EOF Then
    Error_Msg = "Login Failed. Try Again."
    ShowLogin
    Else
    Session("UserLoggedIn") = "true"
    Response.Redirect "protectedpage.asp"
    End If
    End Sub
    %>
     
    solarthur01@hotmail.com, Oct 17, 2007 IP
  2. iShopHQ

    iShopHQ Peon

    Messages:
    644
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #2
    if line 56 is the set rs, then there's a problem with your SQL satement

    after you build the SQL, write it out to check it

    before the set rs put:

    response.write(sql)
    response.end
     
    iShopHQ, Oct 19, 2007 IP