try this code...
qry = "select * from department_master where dep_code='" + txt_code_add.Text + "'";
sql_cmd = new SqlCommand(qry, sql_con);
sql_con.Open();
sql_rs = sql_cmd.ExecuteReader();
if (sql_rs.Read())
{
}
else
{
}
i hope this code helps you a bit..