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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stored procedure has too many arguments specified 1

Status
Not open for further replies.

kel1981b

Programmer
Jan 3, 2003
82
US
Here is my another problem.
I need to check Database for multiple records. To do that
I created code like that
Code:
With cmdReport
        .ActiveConnection = cnReport
        .CommandType = adCmdStoredProc
        .CommandText = strSP_name
        
         If Mid(strSP_name, 16, 2) = "AK" Then
            For i = 0 To lstClients.ListCount - 1
            .Parameters.Append .CreateParameter("@stDate", adVarChar, adParamInput, 10, strToday)
            .Parameters.Append .CreateParameter("@client", adVarChar, adParamInput, 10, lstClients.List(i))
           
           Set rsReport = .Execute
               'some other code not related with  SQL                                                
           Next
        End if
End with

For some reason I keep getting Error like "procedure has too many arguments specified" when program is going second times through the loop. Seems to me something (I thing .Parameters) must be refreshed after every lap in loop. I tried to use .Refresh/Delete methods but it did not help. Thakx a lot for any help/advisw
 
Dim x As Integer

Then add this before the append

For x = 0 To .Parameters.Count - 1
.Parameters.Delete (x)
Next

hope it helps

cjw
 
You are adding two parameters each time you are going through the loop. Just change the parameter values inside the loop. Try,

With cmdReport
.ActiveConnection = cnReport
.CommandType = adCmdStoredProc
.CommandText = strSP_name

If Mid(strSP_name, 16, 2) = "AK" Then
.Parameters.Append .CreateParameter("@stDate", adVarChar, adParamInput, 10)
.Parameters.Append .CreateParameter("@client", adVarChar, adParamInput, 10)
For i = 0 To lstClients.ListCount - 1
.Parameters("@stDate").value = strToday
.Parameters("@client").value = lstClients.List(i)

Set rsReport = .Execute
'some other code not related with SQL
Next
End if
End with
Thanks and Good Luck!

zemp
 
Thanks SonOfEmidec1100 and zemp. I'll try it tomorrow
 
Thanks zemp. You are good! In my 1000 points scale, you got 2000.
 
Glad to be of help. Thanks and Good Luck!

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top