Last post Jul 28, 2015 05:51 AM by Nan Yu
Jul 27, 2015 02:43 PM|Umair Khnx|LINK
Using ASP.NET 2.0 C# I am looking to get some idea how to reduce the quantity as the user buys a product. In my database i have a quantity column and when the user buys an amount of a certain product i would like it to deduct this from my quantity available.
Does anyone have any hints where to start with this? I am certain i am starting in the right place with:
please share the video.. please please please..
its a humble request to you .. share the video for this...
I will remember u all in my prayers.
thanks a lot.
Jul 27, 2015 11:33 PM|Rion Williams|LINK
You would most likely just execute a bit of SQL that would update the Quantity for a specific item and reduce it by one on the row that pertains to that particular item after the item has been purchased. An example query might look something like :
SET Quantity = Quantity - 1
WHERE YourItemId = @YourItemID
I suppose this depends on how your application is structured, but that should give you a general idea. If you have any additional information or details on the type of data provider you are using (ADO.NET, Entity Framework, etc.) we could probably provide
a more detailed response.
Jul 28, 2015 05:51 AM|Nan Yu|LINK
Hi Umair Khnx,
Thanks for your post and welcome to ASP.NET Forum .
In my database i have a quantity column and when the user buys an amount of a certain product i would like it to deduct this from my quantity available. Does anyone have any hints where to start with this?
You could use ADO.NET to update your record in your database ,and when the user buys an amount of a certain product ,you could set a SqlCommand to update the quantity ,code below is for your reference:
updateSQL = "UPDATE Your_Table SET ";
updateSQL += "quantity =@quantity ";
updateSQL += "WHERE itemid=@itemid";
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(updateSQL, con);
cmd.Parameters.AddWithValue("@quantity ", yourquantityhere);
int updated = 0;
updated = cmd.ExecuteNonQuery();
catch (Exception err)
For more details and demo ,please refer to links below: