If we are going to analyze the functionality that we are going to do, we could probably think that we will come up in a numerous lines of code. In comparison to the old version of Visual Basic which is VB6 the developer tends to open both the sales and the product. Add the data to sales table and deduct the product quantity in product table. How the operation conducted? The data from sales form are taken and put in a variable. Second, the calling of the database or .mdb file. Then, the storing of the data to the sales table.
After that, the product table will be called to update the specific product quantity. This will really give as a lot of effort in coding the said functionality.
However, the Microsoft Visual Basic itself gives us a short way to the said functionality. We are not going to type a numerous lines of code but we will just use ONE LINE of code for the update of product quantity.
How will we do it?
We will go first in our .xsd in our explorer solution. Find the .xsd that pertains to our sales table. We will add query in our SalesTableAdapter and put the UPDATE SQL Query.
Put this to the Query Builder:
Update Sales SET Qty = ? WHERE Prod_ID = ?
The concept of making this kind of technique is just like what we do in PHP. The SalesTableAdapter is our Class and using the query builder we are making our methods which default name is ScalarQuery.
The way of adding quantity of specific product in our purchase order table is the same. Just follow the method above.