Results 1 to 5 of 5

Thread: Databases again

  1. #1

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772

    Databases again

    I am trying to make a simple login script with the names and passes stored in an Acces 2000 database. It was working fine before, but now when I go to the page I get this:

    Code:
    Microsoft OLE DB Provider for ODBC Drivers error '80040e10' 
    
    [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. 
    
    /auth.asp, line 15
    Here is the code:

    VB Code:
    1. Set oConn = Server.CreateObject("ADODB.Connection")
    2. oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("logins.mdb"))
    3.  
    4. sSQL = "SELECT Name, Password FROM np"
    5. Set oRS = oConn.Execute(sSQL) ' This is line 15

    The strange thing was that this was working fine a few minutes ago.
    Alcohol & calculus don't mix.
    Never drink & derive.

  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Try this:

    "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("logins.mdb")


    Read this from MSDN for more details on why.
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  3. #3

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Well, when i use that line it works, but I can't log in. I'm not sure what I am doing wrong. I am typing the names and passes just like in the database. I attached all the .asp files and the database.
    Attached Files Attached Files
    Alcohol & calculus don't mix.
    Never drink & derive.

  4. #4
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Change the code in your Auth.asp page to this:

    Code:
    <%
    Option Explicit
    
    Dim oConn
    Dim oRS
    Dim sSQL
    Dim sTitle
    Dim sBody
    
    Set oConn = Server.CreateObject("ADODB.Connection")
    oConn.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("logins.mdb"))
    
    sSQL = "SELECT Name, Password FROM np where Name='" & Request.Form("Name") & "' and Password='" & Request.Form("Pass") & "'"
    Set oRS = oConn.Execute(sSQL)
    If Not (oRS.EOF And oRS.BOF) Then
    	sTitle = "Thanks for logging in"
    	sBody = "Now logged in!<br><br><a href='logout.asp'>Log Out</a>"
    Else
    	sTitle = "Login Failed"
    	sBody = "Name and password do not match.<br>Please try again."
    End If
    
    oConn.Close
    Set oRS = Nothing
    Set oConn = Nothing
    
    %>
    <html>
    <head>
    <title><%=sTitle%></title>
    <style>
    body {
      font-family: verdana, arial, helvetica;
      font-size: 12px;
    }
    </style>
    </head>
    <body>
    <%=sBody%>
    </body>
    </html>
    No need to loop through the database. That would take too much time if you had alot of users. Just retrieve the records if they match. And if you have a match, then they are in.
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  5. #5

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Good point. Thanks, you helped a lot.
    Alcohol & calculus don't mix.
    Never drink & derive.

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