5
Answers

how to compare currentdate wth db date using if

guy plz help me in comparing currentdate from db using if statement.
my error is dat nothungnis happening after button click

code:

{
  connect.Open();
  OleDbCommand command = new OleDbCommand();
  command.Connection = connect;
  string query = "select AttendanceDate from AttendanceTable where AttendanceDate=Date()";
  command.CommandText = query;
  OleDbDataReader reader = command.ExecuteReader();

  while (reader.Read())
  {
  // string workername = reader["WorkerName"].ToString();
  string AttDate = reader["AttendanceDate"].ToString();
  string date=DateTime.Now.ToString("yyyy/MM/dd");
 
  if(AttDate==date)
  {
  MessageBox.Show("hi");
  }
 
 
  }
  connect.Close();
  }
Answers (5)