Update database field

  • Thread starter Thread starter zoneal
  • Start date Start date
Z

zoneal

If I've two tables with their values:
cars(carNo,name,color,model,existedquantity) 2-
CustomerOrders(orderNo,carNo,ordered,orderedquantity,orderdate)

I made for each one of them a form by the Windows Form Designer in the
vb.net plate to record data through these forms.

By the way I'm working on an Access db and on the (imports
system.data.oledb provider).

How can I make the( existedquantity) column in the "cars" table
decreases for each ordered car according to the (orderedquantity)
column from the "CustomerOrders"table.
 
Zoneal,

There are thousands answers possible on the way you have made your question.

When I look at your question than the most simple answer is.

Create an SQL statement that does that and process that using

OleDb.OleDBCommand.ExecuteNonQuery

If you want it in VB.Net than it is a question of creating Two DataTables.
Using a relation Cars -> CustomerOrders and do that action in the parent
based on every CustomerOrderRow Child in a For each loop and update the
table than again.

Be aware that what you are doing is a very riscy operation. Doing this twice
will give direct wrong information. It is in my idea better to keep in this
case a field ordered Cars in your Car table, count that in the same way
starting at zero and than subtract that from your field exisitedquantity
giving the economicQuantity (I don't know if this word exist in English).

I hope this helps,

Cor
 
Back
Top