如何更新整个选定的同一列?

How to update an entire selected same column?

我想用另一个值更新整个选定的同一列...

这是我试过的代码,显然它不起作用(错误是数据库中没有更改)

 OleDbConnection con = new OleDbConnection();
        con.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Rock.accdb";
        OleDbCommand cmd = new OleDbCommand();
        cmd.Connection = con;
        con.Open();
        cmd.CommandText = "UPDATE profile SET [year]=@1 WHERE [year]=@2";
        cmd.Parameters.AddWithValue("@1", comboBox1.Text);
        cmd.Parameters.AddWithValue("@2", comboBox2.Text);
        cmd.ExecuteNonQuery();
        con.Close();
        label4.Text = "Updated successfully";
        label4.ForeColor = Color.Green;

敬请见谅,如有疑问请评论...

尝试:

cmd.CommandText = "UPDATE profile SET [year]=? WHERE [year]=?"

并更新参数(必须按照查询中'?'的顺序添加参数)

cmd.Parameters.AddWithValue("?", comboBox1.Text);
cmd.Parameters.AddWithValue("?", comboBox2.Text);