使用多个条件更新

问题描述 投票:0回答:1

我尝试使用C#访问某些文章中的一些代码更新语句,但是我的代码不起作用,数据库未更新仍然为空。请帮助

我不知道从哪里开始,

                OleDbCommand cmd = conn.CreateCommand();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "update tbl1 set jhu = @jhu, name = @name where nocust = @nocust and result = @yes";
                cmd.Parameters.AddWithValue("@jhu", ToDBValue(textBox19.Text));
                cmd.Parameters.AddWithValue("@name", ToDBValue(textBox2.Text));
                cmd.Parameters.AddWithValue("@nocust", ToDBValue(textBox1.Text));
                cmd.Parameters.AddWithValue("@yes", ToDBValue(textBox6.Text));
                cmd.ExecuteNonQuery();
                cmd.Parameters.Clear();
                conn.Close();
                MessageBox.Show("succesfully");

我想更新我的数据库

c# sql ms-access oledb
1个回答
0
投票

您在这里有一个逗号和等号:

update tbl1 set jhu = @jhu, name = @name, = where nocust = @nocust and result = @yes
                                        ^-^----------- Remove these

我也建议指定表限定符,例如:

update tbl1 set tbl1.jhu = @jhu, tbl1.name = @name where tbl1.nocust = @nocust and tbl1.result = @yes
© www.soinside.com 2019 - 2024. All rights reserved.