Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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); //SET[Order Status] = (@OrderStatus)

    MAcon.Open();
    cmd.Parameters.Add("@OrderID", orderID);
    cmd.Parameters.AddWithValue("@OrderStatus", Location.Text);
    cmd.ExecuteNonQuery();
    MAcon.Close();

    MessageBox.Show("Production has begun");
    {
    }
}
Posted
Updated 13-Apr-18 0:19am
v2

1 solution

Remove the comma in:
@OrderStatus,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900