Hi, I need to loop through many invoices which have many items on them. The problem that I ran into is that I need to clear out the arguments for the stored procedure prior to adding new arguments. I tried looking for something with cdm.? but I didn't see anything that would allow me to clear the arguments.
I have built this test in the code below. The first SP works fine, but when I run the second one it has too many arguments, therefore I need to clear them before I start my second SP. I hope that is clear???
I have built this test in the code below. The first SP works fine, but when I run the second one it has too many arguments, therefore I need to clear them before I start my second SP. I hope that is clear???
Code:
Dim cnConn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim prm As New ADODB.Parameter
cnConn.Open "Driver={SQL Server};Server=hhb;Database=HHb;uid=jk;pwd=jk;"
cmd.ActiveConnection = cnConn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "sp_ScannerInsertInvoice"
cmd.Parameters.Append cmd.CreateParameter("Invoice", adChar, adParamInput, 7, "G10015")
cmd.Parameters.Append cmd.CreateParameter("TheDate", adDBTimeStamp, adParamInput, 0, "01/01/2005")
cmd.Parameters.Append cmd.CreateParameter("EmployeeID", adInteger, adParamInput, , 1001)
cmd.Execute
' I NEED TO CLEAR ARGUMENTS HERE, OR IS THERE A BETTER WAY?
cmd.CommandText = "sp_ScannerInsertInvoiceItem"
cmd.Parameters.Append cmd.CreateParameter("Invoice", adChar, adParamInput, 7, "G10011")
cmd.Parameters.Append cmd.CreateParameter("RecNo", adInteger, adParamInput, 9, 555555)
cmd.Parameters.Append cmd.CreateParameter("ItemNum", adChar, adParamInput, 50, "OG5050")
cmd.Parameters.Append cmd.CreateParameter("Location", adChar, adParamInput, 50, "A100")
cmd.Parameters.Append cmd.CreateParameter("Qty", adInteger, adParamInput, 9, 11)
cmd.Execute
Set cmd = Nothing