問題があります。コードを実行すると、「オブジェクト参照がオブジェクトのインスタンスに設定されていません」というエラーが発生します。
plzはそれに関して私に提案します。
コード
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,DeviceCode,Company,Department,Designation,Grade,Team,Location,EmploymentType,Category,HolidayGroup,ShiftGroup,ShiftRoster,Dateofjoining,Dateofconfirmation,Status,DateofResigning,[Sex]) values ('" + txt_empname.Text + "','" + txt_code.Text + "', '" + txt_dcode.Text + "', '" + dp_company.SelectedItem.ToString() + "', '" + dp_department.SelectedItem.ToString() + "', '"+dp_designation.SelectedItem.ToString()+"', '"+dp_grade.SelectedItem.ToString()+"', '"+dp_team.SelectedItem.ToString()+"', '"+dp_location.SelectedItem.ToString()+"', '"+dp_emptype.SelectedItem.ToString()+"', '"+dp_category.SelectedItem.ToString()+"', '"+dp_holigroup.SelectedItem.ToString()+"', '"+dp_shiftgroup.SelectedItem.ToString()+"', '"+dp_shiftroster.SelectedItem.ToString()+"', '"+dp_day.SelectedItem.ToString()+"', '"+dp_month.SelectedItem.ToString()+"', '"+dp_year.SelectedItem.ToString()+"', '"+dp_cday.SelectedItem.ToString()+"', '"+dp_cmonth.SelectedItem.ToString()+"', '"+dp_cyear.SelectedItem.ToString()+"', '"+dp_status.SelectedItem.ToString()+"', '"+dp_rday.SelectedItem.ToString()+"', '"+dp_rmonth.SelectedItem.ToString()+"', '"+dp_ryear.SelectedItem.ToString()+"', '"+rdbtn_male.Checked.ToString()+"', '"+rdbtn_female.Checked.ToString()+"')";
OleDbCommand cmd = new OleDbCommand(query, conn);
cmd.ExecuteNonQuery();
conn.Close();
BindGridData();
}
"ありがとう"