472,954 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,954 software developers and data experts.

loop only deletes first pass

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

Jul 31 '06 #1
3 1014

Jul 31 '06 #2
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"
Aug 1 '06 #3
thanks for the pointers, the problem was a stray space char.

Aug 1 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: stealthwang | last post by:
I'm still very new to Python, after decideding to learn a true programming language (rather then a scripting language, i like to think i'm a intermediate PHP user). I decided for my first project I...
36
by: Remi Villatel | last post by:
Hi there, There is always a "nice" way to do things in Python but this time I can't find one. What I'm trying to achieve is a conditionnal loop of which the condition test would be done at...
0
by: Kingdom | last post by:
I Need some serious help here. strugling novis with ASP and javascript any help would be greatly appreciated The script below does exactly what I want it to do for each product on the two passes...
5
by: Andrew Young | last post by:
How do I loop thru a result set Without using a curosr?
8
by: Jim Langston | last post by:
There's the thing about iterating though a map or vector when you may delete one of the elements, where you simply assign the iterator to the map.erase() statement or increment it if you don't. ...
1
by: pauljturner99 | last post by:
Hi, I'm trying to pass a parameter from a for loop to the nested while loop but only the first counter is passed. Here is the code: dim ctr redim ctr(5) ctr(0) = 2 ctr(1) = 4 ctr(2) = 6
6
by: Raj | last post by:
We have a batch process that deletes about 7-8 million records every day & takes about 30-35 mins to complete. Is there a way to optimize deletes? Below is the statement delete from fact where...
2
by: recordlovelife | last post by:
So I am trying to display a title, date, and content of a wordpress blog. Word press provides nice drop in functions to get the job done with simple names like "the_title", and the "the_content" But...
8
by: Pivot_Tables | last post by:
Hi, I have created a recursive SQL Query in DB2 and it works fine until some point in the tree where the data gets into infinite loop. Below are some sample data from my relationship table. ...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
1
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.