Update database field

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • zoneal@yahoo.com

    #1

    Update database field

    If I've two tables with their values:
    cars(carNo,name ,color,model,ex istedquantity) 2-
    CustomerOrders( orderNo,carNo,o rdered,orderedq uantity,orderda te)

    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.ole db provider).

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

  • Cor Ligthert [MVP]

    #2
    Re: Update database field

    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.OleDBComm and.ExecuteNonQ uery

    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 CustomerOrderRo w 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 exisitedquantit y
    giving the economicQuantit y (I don't know if this word exist in English).

    I hope this helps,

    Cor

    <zoneal@yahoo.c om> schreef in bericht
    news:1149181863 .408970.123940@ f6g2000cwb.goog legroups.com...[color=blue]
    > If I've two tables with their values:
    > cars(carNo,name ,color,model,ex istedquantity) 2-
    > CustomerOrders( orderNo,carNo,o rdered,orderedq uantity,orderda te)
    >
    > 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.ole db provider).
    >
    > How can I make the( existedquantity ) column in the "cars" table
    > decreases for each ordered car according to the (orderedquantit y)
    > column from the "CustomerOrders "table.
    >[/color]


    Comment

    Working...