public void LoadAttendance()
{
DataAdapter = new OleDbDataAdapter("SELECT * FROM AttendanceDatabase where EmpName = '" + txtEmpName.Text + "'", con);
DataTable = new DataTable();
DataAdapter.Fill(DataTable);
dgvAttendance.DataSource = DataTable;
dgvAttendance.Columns[1].DefaultCellStyle.Format = "h:mm tt";
dgvAttendance.Columns[2].DefaultCellStyle.Format = "h:mm tt";
}
I want to search a record in between two dates and Employee Name. Can someone help me about the query? public void FillPresentDays() {
Public void FillPresentDays
{
con.Open();
cmd = new OleDbCommand("Select COUNT(*) from AttendanceDatabase WHERE EmpName =@EmpName and Date between @d1 and @d2", con);
cmd.Parameters.AddWithValue("@EmpName", txtEmpName.Text);
cmd.Parameters.AddWithValue("@d1", dtDate1.Value.Date);
cmd.Parameters.AddWithValue("@d2", dtDate2.Value.Date);
cmd.ExecuteNonQuery();
int count = (int)cmd.ExecuteScalar();
txtPdays.Text = count.ToString();
con.Close();
LoadAttendance();
}
this code is working the datetimepicker used here is the same that i will used in the LoadAttendance.