hi every one. I need some ideas for the calculation. I have a table in the database with field names: Product_id,Name,Description,Quantity,Unit_price

What i want to do is when customer chooses the product, as soon as he/she enters the quantity it should automatically be multiplied by the unit price of that product e.g if unit price is 2pounds and quantity is 5 it should give me result straight away as 10. I am not sure as to how to add codes for a database table and can't seem to find help around

Recommended Answers

Try

qry = "SELECT Product_id, Name, Description, Quantity,     " &
      "       Unit_Price, Quantity*Unit_Price AS TotalCost " &
      "  FROM myTable"
Jump to Post

All 2 Replies

You have a field quantity in the database, is it total quantity available?

Use select query to retrieve the record from the database and with the help of Data Reader, you can fetch the fields in the record and then multiply the quantity and price.

Try

qry = "SELECT Product_id, Name, Description, Quantity,     " &
      "       Unit_Price, Quantity*Unit_Price AS TotalCost " &
      "  FROM myTable"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.