Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Update problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Update problem

 Post Reply Post Reply
Author
ngaisteve1 View Drop Down
Groupie
Groupie
Avatar

Joined: 26 December 2002
Location: Malaysia
Status: Offline
Points: 169
Post Options Post Options   Thanks (0) Thanks(0)   Quote ngaisteve1 Quote  Post ReplyReply Direct Link To This Post Topic: Update problem
    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=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

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
ngaisteve1 View Drop Down
Groupie
Groupie
Avatar

Joined: 26 December 2002
Location: Malaysia
Status: Offline
Points: 169
Post Options Post Options   Thanks (0) Thanks(0)   Quote ngaisteve1 Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
ngaisteve1 View Drop Down
Groupie
Groupie
Avatar

Joined: 26 December 2002
Location: Malaysia
Status: Offline
Points: 169
Post Options Post Options   Thanks (0) Thanks(0)   Quote ngaisteve1 Quote  Post ReplyReply Direct Link To This Post Posted: 18 November 2003 at 12:47am
Ok, I got it. Yahoo! . 100 thanks to Ijamal.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.