ADODB.Command problem???

spinkung

Registered User.
Local time
Today, 23:11
Joined
Dec 4, 2006
Messages
267
Hi,

I have recently (just about) got my head around using the Command colection. However, when i run the execute the first time everything is fine...
i.e.

Dim cmd As New ADODB.Command

...then i append all the parameters....

then..

cmd.Execute.

First time round is fine but the second time it fails becuase there are too many arguments. I assume this is because i need to empty the command collection after i use it the first time. can someone help me on how you do this??

Thanks
 
would it help if i posted the code??.....

Code:
Dim cnn As New ADODB.Connection    'This is an SQL Server connection
Dim cmd As New ADODB.Command
Dim prm1, prm2 As ADODB.Parameter
Dim prmOut As ADODB.Parameter

cnn.CommandTimeout = 200
cnn.Open connString
cmd.CommandText = "[MyDataBase].MyStoredProc"
cmd.CommandType = adCmdStoredProc

Set prm1 = cmd.CreateParameter("@RefNo", adVarChar, adParamInput, 20, ref)
Set prm2 = cmd.CreateParameter("@salePerson", adVarChar, adParamInput, 50, salPer)
Set prmOut = cmd.CreateParameter("@runid", adInteger, adParamOutput, , 0)
          
cmd.Parameters.Append prm1
cmd.Parameters.Append prm2
cmd.Parameters.Append prmOut
cmd.ActiveConnection = cnn

cmd.Execute
myVariable = prmOut.Value

[COLOR="Red"]......I'm guessin that its here i need to empty the paramters/command collection??[/COLOR]

cnn.Close
Set cnn = Nothing
 

Users who are viewing this thread

Back
Top Bottom