Saturday, February 25, 2012

[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?

--NickTry replacing % in place of *.|||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.|||By all means refer to this KBA (http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q169/3/77.asp&NoWebContent=1) to get rid of the issues and follwup.|||That really didn't help me much.|||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

No comments:

Post a Comment