没有给出所需参数的值(No value given for required parameters)

我正在尝试使用帐号创建一个更新帐户昵称但是我收到错误的按钮。

private void change_nickname_Click(object sender, EventArgs e) { try { connection.Open(); OleDbCommand command = new OleDbCommand(); command.Connection = connection; string query = "update customers set [CustomerCode]='" + customercode.Text + "',[CustomerName]='" + customername.Text + "',[Address]='" + customeraddress.Text + "',[PhoneNumber]='" + customerphone.Text + "',[Account]='" + Account + "',[AccountNickname]='" + accountnickname.Text + "',[Overdraft]='" + overdraft.Text + "' where AccountNumber=" + accountnumber.Text + ""; MessageBox.Show(query); command.CommandText = query; command.ExecuteNonQuery(); MessageBox.Show("Data updated successfuly!"); connection.Close(); } catch (Exception ex) { MessageBox.Show("Error: " + ex); } connection.Close(); }

I am trying to make a button that updates account nickname using the account number but Im getting an error.

private void change_nickname_Click(object sender, EventArgs e) { try { connection.Open(); OleDbCommand command = new OleDbCommand(); command.Connection = connection; string query = "update customers set [CustomerCode]='" + customercode.Text + "',[CustomerName]='" + customername.Text + "',[Address]='" + customeraddress.Text + "',[PhoneNumber]='" + customerphone.Text + "',[Account]='" + Account + "',[AccountNickname]='" + accountnickname.Text + "',[Overdraft]='" + overdraft.Text + "' where AccountNumber=" + accountnumber.Text + ""; MessageBox.Show(query); command.CommandText = query; command.ExecuteNonQuery(); MessageBox.Show("Data updated successfuly!"); connection.Close(); } catch (Exception ex) { MessageBox.Show("Error: " + ex); } connection.Close(); }

最满意答案

是的,问题解决了,伙计们感谢所有的帮助。 问题出在这里。

where AccountNumber=" + accountnumber.Text + ""; MessageBox.Show(query);

我把它改成了

where AccountNumber='" + accountnumber.Text + "'"; MessageBox.Show(query);

它以某种方式起作用。

Yeah the problem was solved guys thank for all the help. The problem was here.

where AccountNumber=" + accountnumber.Text + ""; MessageBox.Show(query);

I changed this to

where AccountNumber='" + accountnumber.Text + "'"; MessageBox.Show(query);

And it worked somehow.

更多推荐