Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2003
    Location
    Minnesota
    Posts
    61

    Angry Unanswered: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2

    Heres my code:

    <%
    'Dimension variables
    Dim adoCon 'Holds the Database Connection Object
    Dim rsAddLinks 'Holds the recordset for the new record to be added
    Dim strSQL 'Holds the SQL query to query the database

    'Create an ADO connection object
    Set adoCon = Server.CreateObject("ADODB.Connection")

    'Set an active connection to the Connection object using a DSN-less connection
    adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("links.mdb")

    'Create an ADO recordset object
    Set rsAddLinks = Server.CreateObject("ADODB.Recordset")

    'Initialise the strSQL variable with an SQL statement to query the database
    strSQL = "SELECT tblLinks.URL, tblLinks.Description FROM tblLinks;"

    'Set the cursor type we are using so we can navigate through the recordset
    rsAddLinks.CursorType = 2

    'Set the lock type so that the record is locked by ADO when it is updated
    rsAddLinks.LockType = 3

    'Open the recordset with the SQL query
    rsAddLinks.Open strSQL, adoCon

    'Tell the recordset we are adding a new record to it
    rsAddLinks.AddNew

    'Add a new record to the recordset
    rsAddLinks.Fields("URL") = Request.Form("url")
    rsAddLinks.Fields("Description") = Request.Form("description")

    'Write the updated recordset to the database
    rsAddLinks.Update

    'Reset server objects
    rsAddLinks.Close
    Set rsAddLinks = Nothing
    Set adoCon = Nothing

    'Redirect to the guestbook.asp page
    Response.Redirect "links.asp"
    %>

    When i run the code I get: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2

    Can someone please help?

    --Nick

  2. #2
    Join Date
    Aug 2002
    Location
    Scotland
    Posts
    1,578
    Try replacing % in place of *.
    --Satya SKJ
    Microsoft SQL Server MVP
    [IMG]http://sqlserver-qa.net/google_bart.gif[/IMG]

  3. #3
    Join Date
    Jun 2003
    Location
    Minnesota
    Posts
    61
    Ok, thanks, but now it says

    [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

    Can you help me on this?

    --Nick

    PS: If your wondering, im reletively new at asp thats why I havent been able to figure this out myself.

  4. #4
    Join Date
    Aug 2002
    Location
    Scotland
    Posts
    1,578
    By all means refer to this KBA to get rid of the issues and follwup.
    --Satya SKJ
    Microsoft SQL Server MVP
    [IMG]http://sqlserver-qa.net/google_bart.gif[/IMG]

  5. #5
    Join Date
    Jun 2003
    Location
    Minnesota
    Posts
    61

    Talking

    That really didn't help me much.
    Mr. Lars

  6. #6
    Join Date
    Jun 2003
    Location
    Minnesota
    Posts
    61

    Thumbs up

    thanks for all your help. I figured it out! i was linking to the page directly when i should have been using the page b4 it that links to it...

    if that makes any scence
    Mr. Lars

Posting Permissions

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