Print Page | Close Window

Update problem

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=7345
Printed Date: 31 March 2026 at 11:22pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Update problem
Posted By: ngaisteve1
Subject: Update problem
Date Posted: 17 November 2003 at 6:38pm

I used the below code to update the reservation list. But the problem is these code got problem. See attachment ( http://www.codingforums.com/attachment.php?s=&postid=149684 - http://www.codingforums.com/attachment.php?s=&postid=149 684 ). After I put 2, 5, 10 under quantity column, all quantity value will become 10. I think it takes the last value and update to all records. So, how do I fix it? Thanks.

<%
qty = Request("quantity_fr")
ids = Split( strProductID, ", " ) ' that is COMMA-SPACE
qtys = Split( qty, ", " ) ' that is COMMA-SPACE

For ix = 0 To UBound(ids)
id = ids(ix)
qty = qtys(ix)
SQL = "UPDATE reservationdetails INNER JOIN reservation ON ReservationDetails.ReservationID = Reservation.ReservationID "
SQL = SQL & "SET Quantity = " & qty & " WHERE status = 'temp' "
conn.Execute( SQL )
Next
Response.Write "OK Done!"
response.end




Replies:
Posted By: ljamal
Date Posted: 17 November 2003 at 9:31pm
YOu're not using the ID to limit the update to the correct ID:

Try:
SQL = "UPDATE reservationdetails INNER JOIN reservation ON ReservationDetails.ReservationID = Reservation.ReservationID "
SQL = SQL & "SET Quantity = " & qty & " WHERE status = 'temp' and Reservation.ReservationID = "&id


-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: ngaisteve1
Date Posted: 17 November 2003 at 9:57pm

Still the same result.

Actually, I got 2 tables.

1. Reservation (ReservationID, CustomerID, Reserved_Date, Discount)

2. ReservationDetails (ReservationDetailsID, ReservationID, ProductID, Quantity, Status)

When I add the items to list, the code will insert those items into these 2 tables and set quantity = 0 and status = temp.

Then, when I click view reservation list page, it will display all items added into list under that customerID (session).

So, all quantity at this time is 0 and user will update that quantity and lastly update as batch (which is my initial problem).

Hope this is much clearer. So, how do update as batch here? I will appreciate all help.



Posted By: ljamal
Date Posted: 17 November 2003 at 10:10pm
Instead of using the productID in the form use the ReservationDetailsID which I am assuming is the Primary Key of the table and then the code below should work.


strSQL = "update ReservationDetails set quantity = "&qty&" where ReservationDetailsID = "&ID

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: ngaisteve1
Date Posted: 18 November 2003 at 12:47am
Ok, I got it. Yahoo! . 100 thanks to Ijamal.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net