当我运行我的代码“没有YearlyLimit”时遇到问题然后它运行正常但是当我在插入查询中添加YearlyLimit时会发生错误
“查询值和目标字段的数量不相同。”
protected void btn_Save_Click(object sender, EventArgs e)
{
string str = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:/Users/Geeta/Desktop/eTimeTrackLite1.mdb;Persist Security Info=False;");
OleDbConnection conn = new OleDbConnection(str);
conn.Open();
string query = "insert into LeaveTypes (LeaveTypeFName,LeaveTypeSName,YearlyLimit,Gender) values ('" + txt_leavetypename.Text + "', '" + txt_shortname.Text + "', '" + txt_yearlimit.Text + "', '" + Convert.ToString(rdbtn_all.Checked) + "', '" + Convert.ToString(rdbtn_male.Checked) + "', '" + Convert.ToString(rdbtn_female.Checked) + "')";
OleDbCommand cmd = new OleDbCommand(query, conn);
cmd.ExecuteNonQuery();
conn.Close();
BindGridData();
}
答案 0 :(得分:0)
您正试图在记录中添加太多项目
您正在尝试插入
您需要检查您要进入最后一个字段的项目