@narsiman,
There are some mistakes in your code
1. You must use Parameterized queries instead of concatenating SQL like you did.
2. You are missing the If condition coursedr.Read() which checks whether the query has returned data or not
coursedr = drr.ExecRdr(Sql);
if(coursedr.Read())
{
if (coursedate < Convert.ToDateTime(coursedr[0].ToString().Trim()))
{
Label23.Text = "date must be ";
return;
}
coursedr.Close();
}