Click to See Complete Forum and Search --> : Update multiple rows timing out...help??


Big Daddy Turbo
10-09-2006, 05:21 PM
Hi I was wondering if someone could help me with this problem.

I need to update the quantites column in a stock table so I created a stock update form in asp with headings 'Product Name' and 'Quantity'. Quantity is a text field which is initially prepopulated with stock amounts from the stock table. I've named each text field the same as the stock_id so I can establish which row the new quantity relates to after submission

The end user updates each stock value manually using the form before clicking an update button to submit the form for processing. Here is the start of my problem

I am trying to iterate back through the stock table to update each row. I creat an update statement like this

DO UNTIL rsStockID.eof

rsUpdate = "rs" & update_id

SET rsUpdate = Server.CreateObject("ADODB.Recordset")
rsUpdate.open "UPDATE tbl_stock SET quantity = " & request("qty_" & update_id) & " WHERE stock_id =" & update_id, objConn, 2, 2
rsUpdate.close
rsUpdate = nothing

rsStockID.movenext
LOOP

I'm sure I'm making a massive schoolboy error but why does the script keep timing out and no rows get updated. I'm sure this sort of procedure is common practice for most web developers but I don't know where I'm going wrong. Any advice would be greatly appreciated

Cheers, Andi

russell
10-12-2006, 11:18 PM
you're approaching it all wrong. try this, but i am wondering where update_id comes from. if this doesnt work, post all of the code.

<%
Dim qty

DO UNTIL rsStockID.eof
qty = request("qty_" & update_id)
runUpdate qty, update_id
rsStockID.movenext
LOOP

Sub runUpdate(qty, upId)
Dim cmd
Dim sql

sql = "UPDATE tbl_stock SET quantity = " & qty & " WHERE stock_id = " & upId
Set cmd = Server.CreateObject("ADODB.Command")

With cmd
.ActiveConnection = YOUR_CONNECTION_STRING
.CommandType = 1
.CommandText = sql

.Execute
End With

Set cmd = Nothing
End Sub
%>