Reputation: 7
If the content in the label matches a cell content in 'column1' (the order ID column) of the database (similar concept to a login form), change value of cell 4 (the order location) in that specific row (and only that row) to specific value in textbox
if (result == DialogResult.Yes) // When the button is clicked and the user selects yes.
{
OleDbDataAdapter da = new OleDbDataAdapter("Select * from [Customer Orders] WHERE [Order ID] = @OrderId", MAcon);
da.SelectCommand.Parameters.AddWithValue("@OrderId", OleDbType.Integer);
// da.SelectCommand.Parameters.Add("@OrderId", OleDbType.Integer).Value = 2;
DataTable dtbl = new DataTable();
da.Fill(dtbl);
if (dtbl.Rows.Count == 1)
{
OleDbCommand cmd = new OleDbCommand("UPDATE [Customer Orders] SET [OrderStatus] = (@OrderStatus), [OrderID]= @OrderId", MAcon); //SET[Order Status] = (@OrderStatus)
MAcon.Open();
cmd.Parameters.AddWithValue("@OrderID", orderID);
cmd.Parameters.AddWithValue("@OrderStatus", Location.Text);
cmd.ExecuteNonQuery();
MAcon.Close();
MessageBox.Show("Production has begun");
}
could someone help me as of now, every cell in column 4 changes and I'm not sure what I've done wrong
Upvotes: 0
Views: 52
Reputation: 1289
This line:
OleDbCommand cmd = new OleDbCommand("UPDATE [Customer Orders] SET
[OrderStatus] = (@OrderStatus), [OrderID]= @OrderId", MAcon);
Needs a WHERE
clause.
Based on your description in the question, possibly:
WHERE column1 = labelContent
Upvotes: 1