English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am doing a programming on visual studio.net 2003 using the Asp.net mobile Web form. I am trying to update the Microsoft access database that i have created using the statement : Update.
According to the Update Statement that i had written, It directly replaces the value in the attribute of the table. Which is not what i am looking for. here's my quote of example for a better explanation:

I have a table name : Pen
Attributes are : ItemID, Color,Quantity,ItemDetails

As such my quantity inside have 10 and when i want to order another 40, i do not want it to replace to 40. i want to replace it to show 50. As such its an addition method.

However in my Update sentence it overwrite it. Is there any other method to make it add?Thanks. Its urgent.

2007-01-07 15:38:50 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

Well, In the Database have an initial value. so in the SQL statement , how to make it read the value in the text box and the value in the database to automatically add it together? It is because the SQL statement should be reading from the database in Microsoft access and then add on the the value in the text box. So is there any method? sub query method is it able? i am not sure how to use the SQL sub query Method even after looking at it. Is there any simpler explanation of how to use it? Thanks.

2007-01-07 18:50:31 · update #1

2 answers

Chetan is right, except you don't need the WHERE clause. You just want it to look at whatever the current quantity is and add the new quantity to the old.
So..Set Quantity = Quantity + 40

2007-01-07 16:02:05 · answer #1 · answered by rod 6 · 0 1

Your query should be like this:

Update Pen set Quantity=Quantity+40 where Quantity=10

got it ??

2007-01-07 15:42:56 · answer #2 · answered by Anonymous · 0 0

fedest.com, questions and answers