Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Too many arguments specified?

Too many arguments specified?

Too many arguments specified?

(Previously posted in SQL forum)
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!


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


CREATE PROCEDURE dbo.MyProcedureName

@Parameter varchar(9)


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


RE: Too many arguments specified?

with a varchar data type, you need to pass the length of the field.

    .Parameters.Append .CreateParameter("@Parameter", adVarChar, adParamInput, 9, Trim(FormField.Value),9)

Also, I would check the value in the field before sending.

Dim avar as string
avar = Trim(FormField.Value)
debug.print avar
Also add some error checking on the field such as check for NULL.
nz(Trim(FormField.Value),"plug something") and then check.

RE: Too many arguments specified?

you can just use the parameters collection itself and do not need to append the parameter at all...


with com

   .parameters("@parameter") = someValue

end with

Procrastinate Now!

RE: Too many arguments specified?


Thanks both. As it turns out, the error message only indirectly related to my problem. My Command object variable had been used once already in my code and I had been trying to reset the parameters for it and reuse it before doing Set Com = Nothing at the end. Once I changed it so there's a Set Com = Nothing after each use and a set Com = New ADODB.Command before the following use, everything went fine. Oops!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close