vbscript - Correct way to reuse ADODB.Command -
what correct way call sproc within loop?
if come in this:
connection = createobject("adodb.connection") until rs.eof set cmd = server.createobject ("adodb.command") cmd.activeconnection = connection cmd.commandtext = "spmysproc" cmd.commandtype = adcmdstoredproc cmd.parameters.append cmd.createparameter ("@p1",adinteger,adparaminput, ,rs("val1")) cmd.parameters.append cmd.createparameter ("@p2",adinteger,adparaminput, ,rs("val2")) cmd.execute set cmd = nothing loop
then on second , subsequent iterations of loop error
procedure or function spmysproc has many arguments specified.
you need separate command preparation , loop. can use parameters collection multiple times execute command.
'preparing command set cmd = createobject ("adodb.command") cmd.activeconnection = connection cmd.commandtext = "spmysproc" cmd.commandtype = adcmdstoredproc cmd.parameters.append cmd.createparameter("@p1", adinteger, adparaminput,,0) '0 placeholder cmd.parameters.append cmd.createparameter("@p2", adinteger, adparaminput,,0) '0 placeholder until rs.eof cmd.parameters("@p1").value = rs("val1").value cmd.parameters("@p2").value = rs("val2").value cmd.execute rs.movenext loop
Comments
Post a Comment