When i run the code i get the constant error of '
No value given for one or more required parameters
' But I have checked and im not sure where it is. the code states that:
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
private void SrtBtn_Click(object sender, EventArgs e)
{
OleDbDataAdapter da = new OleDbDataAdapter("Select * from [Customer Orders] Where [Order ID] = @OrderID", MAcon);
da.SelectCommand.Parameters.AddWithValue("@OrderID", orderID.Text);
DataTable dtbl = new DataTable();
da.Fill(dtbl);
if (dtbl.Rows.Count == 1)
{
OleDbCommand cmd = new OleDbCommand("UPDATE CustomerOrders SET OrderStatus= @OrderStatus WHERE OrderID = @orderId", MAcon);
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 please
What I have tried:
if (dtbl.Rows.Count == 1)
{
OleDbCommand cmd = new OleDbCommand("UPDATE [Customer Orders] SET OrderStatus = @OrderStatus, "
+ "WHERE OrderID = @orderId", MAcon);
MAcon.Open();
cmd.Parameters.Add("@OrderID", orderID);
cmd.Parameters.AddWithValue("@OrderStatus", Location.Text);
cmd.ExecuteNonQuery();
MAcon.Close();
MessageBox.Show("Production has begun");
{
}
}