Click here to Skip to main content
15,896,359 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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");
    }


What I have tried:

private void SrtBtn_Click(object sender, EventArgs e)
{
    DialogResult result = MessageBox.Show("Are you ready to start production", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
    if (result == DialogResult.Yes)
    {
            OleDbCommand cmd = new OleDbCommand("UPDATE [Customer Orders] SET [OrderStatus] = (@OrderStatus) WHERE [OrderID]= '" + orderID.Text + "' ", MAcon);

            MAcon.Open();
            cmd.Parameters.Add("@OrderID", orderID);
            cmd.Parameters.AddWithValue("@OrderStatus", Location.Text);
            cmd.ExecuteNonQuery();
            MAcon.Close();
            MessageBox.Show("Production has begun");
        }


    }
Posted
Updated 12-Apr-18 8:15am
v3
Comments
BillWoodruff 12-Apr-18 14:22pm    
"If the content in the label matches a cell content in 'column1'

the code you show here does not show a Label being accessed.
Member 13512434 12-Apr-18 14:26pm    
hi, I thought 'OleDbCommand cmd = new OleDbCommand("UPDATE [Customer Orders] SET [OrderStatus] = (@OrderStatus) WHERE [OrderID]= '" + orderID.Text + "' ", MAcon);'
would be the accessing of the label?
BillWoodruff 12-Apr-18 14:45pm    
In this case, you need to define what the Label IS and WHERE the Label is.

See my comment on your other question.

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