Every time your loop runs it's decrementing a number by whatever phaseNum happens to be for each record, so if lowNum starts at 0, and you have five records (with a PhaseNum of 1, 2, 3, 4 and 5) then lowNum is going to end up being -15. THEN you're writing lowNum back. I think what you want is for the SELECT and UPDATE statements to both be inside the loop. (you might need to use a second SqlConnection object for the update)
Main Topics
Browse All Topics





by: tgerbertPosted on 2009-11-04 at 09:16:51ID: 25741575
Just subtract 1?
lowNum = rs("phaseNum")
lowNum = lowNum - 1