我在文本框中输入值后
点击‘保存’按钮将信息插入表Amove中!
可是系统说 '插入错误: 列名或所提供值的数目与表定义不匹配。'
我实在无奈了,哪位大虾帮帮忙啊!.................
string sql = string.Format("insert into Amove values ('{0}','{1}','{2}','{3}','{4}','{5}''{6}','{7}','{8}')", txtANo.Text, txtAName.Text, txtOldman.Text, txtNewman.Text, txtOutdpm.Text, cboIndpm.Text, txtOutoff.Text, cboInoff.Text, txtRetry.Text);
SqlCommand command = new SqlCommand(sql, DBHelper.conn);
DBHelper.conn.Open();
result = (int)command.ExecuteScalar();
if (result == 1)
{
MessageBox.Show("添加记录成功!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
.................
点击‘保存’按钮将信息插入表Amove中!
可是系统说 '插入错误: 列名或所提供值的数目与表定义不匹配。'
我实在无奈了,哪位大虾帮帮忙啊!.................
string sql = string.Format("insert into Amove values ('{0}','{1}','{2}','{3}','{4}','{5}''{6}','{7}','{8}')", txtANo.Text, txtAName.Text, txtOldman.Text, txtNewman.Text, txtOutdpm.Text, cboIndpm.Text, txtOutoff.Text, cboInoff.Text, txtRetry.Text);
SqlCommand command = new SqlCommand(sql, DBHelper.conn);
DBHelper.conn.Open();
result = (int)command.ExecuteScalar();
if (result == 1)
{
MessageBox.Show("添加记录成功!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
.................
所以在insert语句没显式插入!
一般建议
insert 表名(列名,) values(....)
写法,省略了容易出现错误