我有一个问题,当我运行我的代码时,会发生错误,即“” System.Data.OleDb.OleDbException:标准表达式中的数据类型不匹配。“”。数据类型是数字。
请就此向我提出建议。
"代码
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 Employees (EmployeeName,EmployeeCode,Designation,Grade,Team,Location,EmployementType,HolidayGroup) values ('" + txt_empname.Text + "','" + txt_code.Text + "', '"+ Convert.ToString(dp_designation.SelectedItem)+"', '"+Convert.ToString(dp_grade.SelectedItem)+"', '"+Convert.ToString(dp_team.SelectedItem)+"', '"+Convert.ToString(dp_location.SelectedItem)+"', '"+Convert.ToString(dp_emptype.SelectedItem)+"', '"+Convert.ToString(dp_holigroup.SelectedItem)+"')";
OleDbCommand cmd = new OleDbCommand(query, conn);
cmd.ExecuteNonQuery();
conn.Close();
BindGridData();
}
“谢谢”