Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends,
I have been trying to set up a database in VB 2010.
I have a table Called: Sales, which contains following columns,
Price, Quantity, Tax and Amount.
What I wish to do is, Multiply, Price, Quantity and Tax data to Amount Column instantly as the above fields are entered.
I have created a database using MSSql.
When I try adding a query to the default TableAdapter, it gives something called as Schema error.
So, I added a new Adapter and a query,
SELECT PRICE, TAX, Quantity, PRICE*TAX*Quantity AS Amount FROM sales
It got executed correctly, but I am unable to get it working with the table.
What should i do?
Posted

One way is to use CellValidated[^] event and place your calculations in there.

If you use a data table as underlying data source, you could also consider adding a computed column in the data table.
 
Share this answer
 
Comments
Sandeep Mewara 10-May-12 23:11pm    
Yep 5!
Wendelius 11-May-12 0:55am    
Thanks :)
Please refer following threads:

This article demonstrates how to develop client side calculations in a GridView, and calculation expressions are configurable at the DB side:
Database driven client side calculations in GridView[^]

Using JavaScript/JQuery:
Calculating GridView total using JavaScript/JQuery[^]

How To Add client side calculation for gridview column[^]
Display Sum Total in the Footer of the GridView Control[^]

GridView Examples for ASP.NET: Displaying Summary Data in the Footer[^]
Displaying Summary Information in the GridView's Footer[^]

Check similar discussion on following link:
Calculate Total Value In Gridvew In ASP.net C#[^]

Hope you get some needful from it!
 
Share this answer
 
Comments
Sandeep Mewara 10-May-12 23:12pm    
Based on tags, it looks like a winform and not ASP.NET.

Might be OP has not tagged correctly.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900