Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Too many arguments specified?

Status
Not open for further replies.

ChopinFan

Technical User
Oct 4, 2004
149
US
I am trying to execute a simple select query in an ADP file via code and I’m getting an error message saying the sproc has “too many arguments specified”. It’s a very simple query and I don’t see what I’m doing wrong. "Com" is my command object variable and "Con" is my connection object variable, both of which are working fine. I've searched the FAQs but found nothing. Thanks!

Code:

With Com
.ActiveConnection = Con
.CommandType = adCmdStoredProc
.CommandText = "dbo.MyProcedureName"
.Parameters.Append .CreateParameter("@Parameter", adVarChar, adParamInput, 9, Trim(FormField.Value))
End With
Set MyRecordset = Com.Execute


Sproc:

CREATE PROCEDURE dbo.MyProcedureName

@Parameter varchar(9)

AS

SELECT Field
FROM dbo.Table
WHERE (Field = @Parameter)

GO
 
You are appending a parameter. If the code is called more than once, won't another parameter be added to the collection? Try removing any parameters first.
 
I'm not quite sure I follow. I use the same code layout in many cases where information is retrieved to populate recordsets or add/update data in the database and it works without a problem. I don't see what I'm doing differently in this case.
 
Well then I think you need to post this in the appropriate forum, VBS I am guessing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top