Error opening recordset - 'Too few parameters'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • emvy681
    New Member
    • Aug 2008
    • 2

    Error opening recordset - 'Too few parameters'

    I have a problem on programming, i am not that good but i can read and implement some programs.

    I just wanna ask help on this code

    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
    [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
    /pang/view_station.as p, line 14
    which is "myrec.Open sql"

    i did all suggestion from the net but still i can't solve it.
    Any help is higly appreciated.

    thanks
    Meynard

    Code:
    <% 
    Session("GB_DATABASE") = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("_db/links.mdb")  
    Set Conn = Server.CreateObject("ADODB.Connection")  
    Conn.Mode = 3
    Conn.Open Session("GB_DATABASE")
    %>
    <%
    Set myrec = Server.CreateObject ("ADODB.Recordset")
    Set myrec.ActiveConnection = conn
    Dim sql
    sql = "select * from station WHERE name =" & Request.QueryString("neym")
    myrec.CursorType = 3
    myrec.Open sql
    %>
    Last edited by DrBunchman; Aug 1 '08, 07:07 AM. Reason: Added [Code] Tags - Please use the '#' button
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi Meynard,

    Welcome to Bytes! I hope you find the site useful. Please take the time to read the Posting Guidelines. Please also wrap any code you print in CODE tags using the # button at the top of the editor window as they make your posts much easier to read.

    The problem is that you haven't specified the connection you are using to open your recordset. Try the following instead:
    Code:
    myrec.Open sql, conn
    Hope this helps,

    Dr B

    Comment

    • Jerry Winston
      Recognized Expert New Member
      • Jun 2008
      • 145

      #3
      Originally posted by emvy681


      Code:
      <% 
      Session("GB_DATABASE") = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("_db/links.mdb")  
      Set Conn = Server.CreateObject("ADODB.Connection")  
      Conn.Mode = 3
      Conn.Open Session("GB_DATABASE")
      %>

      looks like you're missing your connectionstrin g. Use your session variable GB_DATABASE as the connection string. try this:
      Code:
      <% 
      Session("GB_DATABASE") = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("_db/links.mdb")  
      Set Conn = Server.CreateObject("ADODB.Connection")  
      Conn.Mode = 3
      Conn.connectionstring Session("GB_DATABASE")
      Conn.Open 
      %>

      Comment

      Working...