0
//every time i execute the NewBind() it subtract all of the same product name in the inventory out and update the inventory.

private void NewBind()
{
    try
    {
        MySqlConnection con = new MySqlConnection("connection..");
        con.Open();
        MySqlCommand cmd = con.CreateCommand();
        cmd.CommandText = "update inventoryOut.TotalPrice = (inventory.TotalPrice - inventoryout.TotalPrice) where inventory.Product = @Products";
        cmd.Parameters.AddWithValue("@Products", cbProductOut.SelectedItem.ToString());
        cmd.Prepare();
        cmd.ExecuteNonQuery();
        BindGridInventory();
        con.Close();
    }
    catch(Exception t)
    {
        MessageBox.Show(t.Message);
    }
}

//sample
inventory DB(lets assume that this is already deducted product 1 10 stocks)
Product 1   100 stocks   1000 Total Price
Product 2   50  stocks   500  Total Price

inventoryOUT BD(let assume the last value is the updated)
Product 1   10  stocks   100  Total Price
Product 1   50  stocks   500  Total Price

..not desired output
newBind():
inventory DB
Product 1   40  stocks    400 Total Price
Product 2   50  stocks    500 total Price

..desired output
newBind():
inventory DB
Product 1   50  stocks    500 Total Price
Product 2   50  stocks    500 total Price
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
bluRe
  • 5
  • 3
  • You need to join your inventory table in your query. See here: http://stackoverflow.com/questions/15209414/mysql-update-join – Erik Mar 11 '15 at 16:37
  • do i still need the @Product? – bluRe Mar 11 '15 at 16:41
  • Probably, if you want to update a specific product. I don't really have a clear understanding of what you're trying to do though. – Erik Mar 11 '15 at 17:20

0 Answers0