this may not be 100% currect but it will give some idea
cmd = new SqlCommand("select * from timetable where clo1='"+CLASS_ID.Text+"' and col2='"+TIME.Text+"'", con);
dr = cmd.ExecuteReader();
if(!dr.HasRows)
{
String str = "insert into TIMETABLE values ('" + SUBJECT_CODE.Text + "','" + OFFER_ID.Text + "','" + CLASS_ID.Text + "','" + DropDownList1.SelectedItem + "','" + TIME.Text + "','" + FACULTY_ID.Text + "','" + DropDownList2.SelectedItem + "','" + DURATION.Text + "') ";
cmd2 = new SqlCommand(str, con);
cmd2.ExecuteNonQuery();
}