Where is the command object defined? It looks like it may be global, in
which case, the second time around you are creating and adding the
parameters all over again, and they are already there from the first time.
You should probably create the parameters at the time you create the command
object, then just assign the parameter values in the code you posted.
--
Jeff Mason Custom Apps, Inc.
Jeff@c...
-----Original Message-----
From: Richard Hadfield [mailto:Richard.Hadfield@t...]
Sent: Wednesday, November 20, 2002 12:19 PM
To: sql language
Subject: [sql_language] ADO Error
Written the code below which works first time, but when you run it the
second time I am getting this error!!??
Error:
Procedure or function sp_GetNextMonthYear has too many arguments specified.
Do I need to clear something??
Code:
Private Sub spStart()
On Error GoTo ErrorHandler
cn.Provider = "sqloledb"
provStr = "Server=migdev02;Database=nxstxs;Trusted_Connection=yes"
cn.Open provStr
Set cmd.ActiveConnection = cn
cmd.CommandText = "sp_GetNextMonthYear"
cmd.CommandType = adCmdStoredProc
'Set up a return parameter.
Set param1 = cmd.CreateParameter("Return", adInteger, adParamReturnValue)
cmd.Parameters.Append param1
' Input parameter. Bind Number
Set param2 = cmd.CreateParameter("Input", adVarChar, adParamInput, 7)
cmd.Parameters.Append param2
'royalty = Trim(InputBox("Enter Aggregate Number :"))
param2.Value = "307 299" 'royalty
' Set up 1st output parameter. Month
Set param3 = cmd.CreateParameter(, adVarChar, adParamOutput, 2)
cmd.Parameters.Append param3
' Set up 2nd output parameter. Year
Set param4 = cmd.CreateParameter(, adVarChar, adParamOutput, 4)
cmd.Parameters.Append param4
' Execute command
cmd.Execute, adExecuteno
Debug.Print "Bindno entered: " & param2
Debug.Print "Month: " & param3
Debug.Print "Year: " & param4
Debug.Print param1
cn.Close
End Sub
NOTICE AND DISCLAIMER:
This email (including attachments) is confidential. If you have received
this email in error please notify the sender immediately and delete this
email from your system without copying or disseminating it or placing any
reliance upon its contents. We cannot accept liability for any breaches of
confidence arising through use of email. Any opinions expressed in this
email (including attachments) are those of the author and do not necessarily
reflect our opinions. We will not accept responsibility for any commitments
made by our employees outside the scope of our business. We do not warrant
the accuracy or completeness of such information.