You need to use the ExecuteScalar
method like this:
SqlCommand cmd = new SqlCommand("select rent_panel from parameters where id= '1'", con);
con.Open();
bool rent_panel = (bool)cmd.ExecuteScalar();
if (rent_panel == true)
{
//..
}
else
{
//..
}
Please note that based on your question, I am assuming that the rent_panel
column is of type bit
(it can be either true or false).
I am assuming also that the id column has unique values (it is the primary key, right?)
Side note: you should always dispose your connection and command objects using the using
keyword. Take a look at this answer.