[quoted text, click to view] Jon Paal wrote:
> why is this code only deleting on the first pass when there is more
> than one item in the array?
> checking the array shows all items are present, lower and upper
> bounds are correct
> if the array holds only one item it always works
>
> ==============================================
>
> Set oConn = Server.CreateObject("ADODB.Connection")
> oConn.Open Connstring
> arrPlayers = split(strPlayers,",")
>
> For i = Lbound(arrPlayers) to Ubound(arrPlayers)
> if IsObject(rs) then set rs=nothing
> strSQL = "Delete FROM playoffs p WHERE p.Playercode= " &
> arrPlayers(i) set rs = oConn.execute(strSQL)
> Next
>
> Set rs = nothing
> oConn.close
> Set oConn = nothing
Nothing to do with your problem, but, in vbscript, calling the lbound
function is a waste of time: it will always return 0.
Again, unrelated to your problem, but why are you using a recordset to
execute a query that returns no records? What a waste of time and resources.
A simple
oConn.execute strSQL,,129
will be much more efficient. The 129 is the combination of two constants:
adCmdText (1) which tells ADO that you are executing a string containing a
sql statement, and adExecuteNoRecords (128) which tells ADO not to construct
a recordset because the query will not be returning records
Now, onto your problem, which is going to require some debugging:
response.write "strPlayers contains """ & strPlayers & """<br>"
arrPlayers = split(strPlayers,",")
response.write "Ubound(arrPlayers) returns " & _
Ubound(arrPlayers) & "<br>"
for i = 0 to Ubound(arrPlayers)
val=arrPlayers(i)
response.write "arrPlayers(" & i & ") contains """ & _
arrPlayers(i) & """<br>"
strSQL = "Delete FROM playoffs p WHERE p.Playercode= " & _
val
Response.Write "Executing """ & strSQL & """<BR>"
oConn.execute strSQL,,129
next
Run the page and look at the results.
If this does not give you the clue you need then show us the results
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"