Sheffer Fernandes

Sheffer Fernandes

  • NA
  • 15
  • 3.2k

how to compare currentdate wth db date using if

Feb 5 2015 1:08 AM
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)