0

Hi,
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:

    protected void btnBuyNow_Click(object sender, EventArgs e)
    {
        //I NEED CODE HERE TO DEDUCT VALUE??
        Response.Redirect("Order.aspx");
    }

Thanks

4
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by M.Waqas Aslam
0

When user buy a product then deduct it with present quantity. Check must be applied for quantity value. And update the new reading in the database.

0

Assuming you understand the SQL UPDATE command, you simply execute a command on the database (command.executeNonquery in .Net)to set the quantity to the new quantity based on the product code.

UPDATE products_table SET quantity = quantity - 2 WHERE product_code = ?code;

Obviously the table name, column name and quantity to subtract will differ for you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.