Here's the scenario. My stored proc (on SQL Server 2000) reads thus:

CREATE PROCEDURE dbo.spContactUpdate
(@ContactName nvarchar(50),
@FirstName nvarchar(50) = null,
@LastName nvarchar(50) = null,
@Address1 nvarchar(50) = null,
@Address2 nvarchar(50) = null,
@City nvarchar(50) = null,
@ST nvarchar(50) = null,
@Zip nvarchar(10) = null,
@Phone1 nvarchar(50) = null,
@Phone2 nvarchar(50) = null,
@Fax nvarchar(50) = null,
@Cell nvarchar(50) = null,
@email nvarchar(50) = null,
@ContactID int
)

AS

Update [dbo].[contacts]
set [ContactName] = @ContactName,
[FirstName] = @FirstName,
[Address1] = @Address1,
[Address2] = @Address2,
[City] = @City,
[ST] = @ST,
[Zip] = @Zip,
[Phone1] = @Phone1,
[Phone2] = @Phone2,
[Fax] = @Fax,
[Cell] = @Cell,
[email] = @email
Where Contact_ID = @ContactID

My ASP code reads like this:
cmd.CommandType = AdCmdStoredProc
cmd.CommandText = "spContactUpdate"
cmd.parameters.refresh

'cmd.Parameters.Append cmd.CreateParameter ("RETURN_VALUE",
adInteger, adParamInput, NULL)
cmd.parameters("@RETURN_VALUE") = NULL
cmd.parameters("@ContactName") = strContactName
cmd.parameters("@FirstName") = strFirstName
cmd.parameters("@LastName") = strLastName
cmd.parameters("@Address1") = strAddress1
cmd.parameters("@Address2") = strAddress2
cmd.parameters("@City") = strCity
cmd.parameters("@ST") = strST
cmd.parameters("@Zip") = strZip
cmd.parameters("@Phone1") = strPhone1
cmd.parameters("@Phone2") = strPhone2
cmd.parameters("@Fax") = strFax
cmd.parameters("@Cell") = strCell
cmd.parameters("@email") = stremail

Set paramId = cmd.CreateParameter("@contactid", adInteger,
adParamInput, , strContactID)
cmd.Parameters.Append paramId
cmd.Execute

(for the @ContactID param, I had to write it this way for it to even
run past this point.)

I get the error, "Procedure or function spContactUpdate has too many
arguments specified.", and I check the params by iterating through
them, and get this:

@RETURN_VALUE:
@ContactName: A Little Mouse
@FirstName: Mickey
@LastName: Mouse
@Address1: Addr2
@Address2: Addr2
@City: Burgerville
@ST: AL
@Zip: 38501
@Phone1: 910-290-3942
@Phone2: MyPhone2
@Fax: 801-653-7029
@Cell: 910-444-0932
@email: elbjay2000@mailinator.com
@ContactID:

The first parameter, @RETURN_VALUE, shouldn't be there, and I can't
get rid of it. Outside of this, I think it should work like a charm.

I can't say why my contactID doesn't show at this point. Sorry for all
the details, but I know this is complicated and I wanted to give all
the facts.

Any advice? (please)

Thx!

Re: Procedure...has too many arguments specified (?) by Anthony

Anthony
Tue Jan 29 02:35:06 CST 2008

"javelin" <jmevalentin@gmail.com> wrote in message
news:bd8b7768-0d80-42d2-a0fb-2e412227c823@y5g2000hsf.googlegroups.com...
> Here's the scenario. My stored proc (on SQL Server 2000) reads thus:
>
> CREATE PROCEDURE dbo.spContactUpdate
> (@ContactName nvarchar(50),
> @FirstName nvarchar(50) = null,
> @LastName nvarchar(50) = null,
> @Address1 nvarchar(50) = null,
> @Address2 nvarchar(50) = null,
> @City nvarchar(50) = null,
> @ST nvarchar(50) = null,
> @Zip nvarchar(10) = null,
> @Phone1 nvarchar(50) = null,
> @Phone2 nvarchar(50) = null,
> @Fax nvarchar(50) = null,
> @Cell nvarchar(50) = null,
> @email nvarchar(50) = null,
> @ContactID int
> )
>
> AS
>
> Update [dbo].[contacts]
> set [ContactName] = @ContactName,
> [FirstName] = @FirstName,
> [Address1] = @Address1,
> [Address2] = @Address2,
> [City] = @City,
> [ST] = @ST,
> [Zip] = @Zip,
> [Phone1] = @Phone1,
> [Phone2] = @Phone2,
> [Fax] = @Fax,
> [Cell] = @Cell,
> [email] = @email
> Where Contact_ID = @ContactID
>
> My ASP code reads like this:
> cmd.CommandType = AdCmdStoredProc
> cmd.CommandText = "spContactUpdate"
> cmd.parameters.refresh
>
> 'cmd.Parameters.Append cmd.CreateParameter ("RETURN_VALUE",
> adInteger, adParamInput, NULL)
> cmd.parameters("@RETURN_VALUE") = NULL
> cmd.parameters("@ContactName") = strContactName
> cmd.parameters("@FirstName") = strFirstName
> cmd.parameters("@LastName") = strLastName
> cmd.parameters("@Address1") = strAddress1
> cmd.parameters("@Address2") = strAddress2
> cmd.parameters("@City") = strCity
> cmd.parameters("@ST") = strST
> cmd.parameters("@Zip") = strZip
> cmd.parameters("@Phone1") = strPhone1
> cmd.parameters("@Phone2") = strPhone2
> cmd.parameters("@Fax") = strFax
> cmd.parameters("@Cell") = strCell
> cmd.parameters("@email") = stremail
>
> Set paramId = cmd.CreateParameter("@contactid", adInteger,
> adParamInput, , strContactID)
> cmd.Parameters.Append paramId
> cmd.Execute
>
> (for the @ContactID param, I had to write it this way for it to even
> run past this point.)
>
> I get the error, "Procedure or function spContactUpdate has too many
> arguments specified.", and I check the params by iterating through
> them, and get this:
>
> @RETURN_VALUE:
> @ContactName: A Little Mouse
> @FirstName: Mickey
> @LastName: Mouse
> @Address1: Addr2
> @Address2: Addr2
> @City: Burgerville
> @ST: AL
> @Zip: 38501
> @Phone1: 910-290-3942
> @Phone2: MyPhone2
> @Fax: 801-653-7029
> @Cell: 910-444-0932
> @email: elbjay2000@mailinator.com
> @ContactID:
>
> The first parameter, @RETURN_VALUE, shouldn't be there, and I can't
> get rid of it. Outside of this, I think it should work like a charm.
>
> I can't say why my contactID doesn't show at this point. Sorry for all
> the details, but I know this is complicated and I wanted to give all
> the facts.
>
> Any advice? (please)
>

All stored procedures return an int value. ADO defines this as the first
parameter in parameters collection (item 0). If you're not using it ignore
it. Don't try setting it to a value.

ContactID doesn't show anything because you have set it. Its probably empty
you should set it to null.

--
Anthony Jones - MVP ASP/ASP.NET



Re: Procedure...has too many arguments specified (?) by Bob

Bob
Tue Jan 29 05:47:51 CST 2008

javelin wrote:
> Here's the scenario. My stored proc (on SQL Server 2000) reads thus:
>
> CREATE PROCEDURE dbo.spContactUpdate
> (@ContactName nvarchar(50),
> @FirstName nvarchar(50) = null,
> @LastName nvarchar(50) = null,
> @Address1 nvarchar(50) = null,
> @Address2 nvarchar(50) = null,
> @City nvarchar(50) = null,
> @ST nvarchar(50) = null,
> @Zip nvarchar(10) = null,
> @Phone1 nvarchar(50) = null,
> @Phone2 nvarchar(50) = null,
> @Fax nvarchar(50) = null,
> @Cell nvarchar(50) = null,
> @email nvarchar(50) = null,
> @ContactID int
> )
>
<snip - irrelevant>
>
> My ASP

For future reference, microsoft.public.inetserver.asp.db would probably have
been a better place for this question.

> code reads like this:
> cmd.CommandType = AdCmdStoredProc
> cmd.CommandText = "spContactUpdate"
> cmd.parameters.refresh

Refreshing the Parameters collection every time you execute this stored
procedure is a bad practice. Use CreateParameter to build and append your
parameter objects yourself. There is no need to continue making a second
trip to the database to get the parameter metadata. Since you are using ASP,
if you wish to continue using an explicit Command object, you would probably
benefit from this free tool I adapted from the VB addin that used to be
available on Bill Vaughn's site:

http://common.mvps.org/barrowsb/ClassicASP_sp_code_generator.zip

>
> 'cmd.Parameters.Append cmd.CreateParameter ("RETURN_VALUE",
> adInteger, adParamInput, NULL)
> cmd.parameters("@RETURN_VALUE") = NULL

<snip>

> The first parameter, @RETURN_VALUE, shouldn't be there, and I can't
> get rid of it. Outside of this, I think it should work like a charm.
>
> I can't say why my contactID doesn't show at this point. Sorry for all
> the details, but I know this is complicated and I wanted to give all
> the facts.
>

As Anthony says: all stored procedures return an Int value that ADO receives
as the first Parameter object.

That said, you are going to too much trouble here. Your procedure uses no
output parameters, and you are not interested in reading the value of the
return parameter, so it is not necessary to use an explicit Command object.
The procedure-as-connection-method technique will simplify your life
immensely. Assuming your connection variable is called "cn", you could do
this:

'explicitly cast the non-string datatypes:
strContactID=CLng(strContactID)

cn.spContactUpdate strContactName, strFirstName, strLastName, _
strAddress1, strAddress2, strCity, strST, strZip, strPhone1, _
strPhone2, strFax, strCell, stremail, strContactID


If you ever modify your stored procedure to make it return a resultset, you
can still use this technique to execute it and return the data to a
recordset:

set rs=createobject("adodb.recordset") 'essential
cn.spContactUpdate strContactName, strFirstName, strLastName, _
strAddress1, strAddress2, strCity, strST, strZip, strPhone1, _
strPhone2, strFax, strCell, stremail, strContactID, rs



--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"



Re: Procedure...has too many arguments specified (?) by Bob

Bob
Tue Jan 29 08:17:23 CST 2008

Bob Barrows [MVP] wrote:
>> 'cmd.Parameters.Append cmd.CreateParameter ("RETURN_VALUE",
>> adInteger, adParamInput, NULL)
>> cmd.parameters("@RETURN_VALUE") = NULL

Oh, and the Return Parameter should have a parameter direction value of
adParamReturnValue, not adParamInput. Do NOT assign a value to this
parameter object. Create and append it to the Parameters collection
without setting its Value property.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.



Re: Procedure...has too many arguments specified (?) by javelin

javelin
Wed Jan 30 22:56:03 CST 2008

On Jan 29, 8:17 am, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:
> Bob Barrows [MVP] wrote:
> >> 'cmd.Parameters.Append cmd.CreateParameter ("RETURN_VALUE",
> >> adInteger, adParamInput, NULL)
> >> cmd.parameters("@RETURN_VALUE") = NULL
>
> Oh, and the Return Parameter should have a parameter direction value of
> adParamReturnValue, not adParamInput. Do NOT assign a value to this
> parameter object. Create and append it to the Parameters collection
> without setting its Value property.
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.

Well, thanks fro all the advice. The mistake I made was in not
specifying the contactid as an output parameter. Making it an output
param fixed the issue.

Thanks for the tips, and references.

Jamie