Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Jul 2005
    Location
    Oxfordshire, UK
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    problem with query

    i have a login script and i am trying to query the database based on the username that is stored in a session, the code i have for this page is below. When i login and it directs me to that page i see the following error:

    Script error detected at line 21.
    Source line: rs.Open strSQL, adoCon, 3, 3
    Description: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.


    I am guessing that i have done summit wrong with the coding of the opening of the database and the query.... can anyone tell me whats wrong with it please....


    Code:
    <%
     username = Session("loginfailure")
     if ("" = username) Then
     response.Write("Sorry, you are not logged in.")
     response.End 
    End if 
    %>
    
    <%
      'Dimension variables
    Dim adoCon    'Holds the Database Connection Object
    Dim rs	'Holds the recordset for the records in the database
    Dim strSQL   'Holds the SQL query for the database
    
    Set adoCon = Server.CreateObject("ADODB.Connection")
    adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("project_database.mdb")
    'adoCon.Open "DSN=login"
    Set rs = Server.CreateObject("ADODB.Recordset")
    
    strSQL = "SELECT * FROM register Where username = '"& Session("username") &"';"
    rs.Open strSQL, adoCon, 3, 3
    
    IF NOT rs.EOF THEN
    
    FName=rs("user_name")
    
    
     rs.Close
    Set rs = Nothing
    adoCon.Close
    Set adoCon = Nothing
    End If
    
    %>
    
    <HTML>
    <head>
    <title>Final Login Page after logged in</title>
    <style>
    </head>
    <body TOPMARGIN=0 LEFTMARGIN=5 MARGINWIDTH=5 MARGINHEIGHT=0>
    <br>
    <br>
    <br>
    <table valign=top border=0 bordercolor="#ffffff" width="100%" cellspacing=0 cellpadding=0>
    <tr>
    <td align="left" valign=top>
      
            <TABLE WIDTH="80%" BORDER="0" CELLSPACING="0" CELLPADDING="1" ALIGN="center" style="border-style: solid; border-color: #0000CC">
              <TR> 
                <TD BGCOLOR="#0000FF" CLASS="hea" HEIGHT="20"> 
                  <DIV ALIGN="center"><font face="Verdana,Arial" color="#ffffff"><b>Final
                    Page</b></font></DIV>
                </TD>
              </TR>
    
              <TR> 
                <TD BGCOLOR="#33ccff"> 
                  <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="8" BGCOLOR="#EFEFEF">
                    <TR> 
                      <TD CLASS="small"> 
                      
    
                  <p align="left"><font size="3" face="Verdana,Arial" color="#0000ff"><B>Congratulation!
                    </B></font>
                
      
                      
                                        
                  <p align="left"><font size="3" face="Verdana,Arial" color="#0000ff"><b>
    <br>You
                  have successfully logged in to our site</b></font><p align="left"><font size="3" face="Verdana,Arial" color="#0000ff">            
                      
                                        
                  <p align="left">&nbsp;
                
                        
                                        
                      </TD>
                    </TR>
                  </TABLE>
                </TD>
              </TR>
            </TABLE> 
    
    
     
    </table>
     Welcome <%Fname%>. 
    <a href="logout.asp">Log out</a>   
    
    </BODY>
    </html>
    Last edited by robojob; 08-12-2005 at 10:28 PM.

  • #2
    Regular Coder
    Join Date
    Sep 2004
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    strSQL = "SELECT * FROM register Where username = '"& Session("username") &"';"
    Ditch the ";" at the end of your select statement.

  • #3
    Regular Coder
    Join Date
    Jul 2005
    Location
    Oxfordshire, UK
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nope still getting this error:

    Script error detected at line 21.
    Source line: rs.Open strSQL, adoCon, 3, 3
    Description: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

  • #4
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    478
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Here are a couple things to try (otherwise no idea):

    Maybe Session("username") is actually blank at the time.

    Or perhaps try this:

    strSQL = "SELECT * FROM [register] Where [username] = '" & Session("username") &"';"
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips

  • #5
    Regular Coder Freon22's Avatar
    Join Date
    May 2005
    Location
    USA
    Posts
    287
    Thanks
    3
    Thanked 5 Times in 5 Posts
    Try doing a Response.Write strSQL to make sure that session("username") has something in it.

  • #6
    Regular Coder
    Join Date
    Jul 2005
    Location
    Oxfordshire, UK
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Bullschmidt
    Here are a couple things to try (otherwise no idea):

    Maybe Session("username") is actually blank at the time.

    Or perhaps try this:

    strSQL = "SELECT * FROM [register] Where [username] = '" & Session("username") &"';"

    That didnt work and i have tried the response.write and the session definatley has something in it, i did that before i did this part to make sure that was working!

    Any other ideas,???

  • #7
    Regular Coder
    Join Date
    Jul 2005
    Location
    Oxfordshire, UK
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sorted it, there was a missing _ between user and name in the query so it was looking for a column in the database that isnt there!!! my fault! thanks for your help!!

  • #8
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    478
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Alright way to go!
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips


  •  

    Posting Permissions

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