string strqry = "select dob from master_studentpersonal where stud_id= '" +
TextBox1.Text + "'";
DataTable dt = mc.selectQryDataTable2(strqry);
DataView dv = new DataView(dt);
DateTime dob = new DateTime();
if (dob != null)
{
if (dob <= new DateTime(2004, 01, 01) &&
dob <= new DateTime(2005, 12, 31))
{
TextBox6.Text = "Group A";
}
else if (dob <= new DateTime(2003, 12, 31) &&
dob <= new DateTime(2002, 01, 01))
{
TextBox6.Text = "Group B";
}
}
plz help me friends
dobwill never be null, both because you assign it and becauseDateTimeis a value type. Doesn’t fix your problem, but it’ll tidy your code 😉More importantly though, you never assign a value to it, so it’s going to pick up an arbitrary value like
DateTime.MinValue(at a guess).