我在“没有 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();
}