title: How to get a bit value with SqlDataReader and convert it to bool?
body: <p>I am retrieving user information from a database using a simple query.</p>
  
  <pre><code>select * from dbo.[User] u where u.Email = @email
  </code></pre>
  
  <p>I then try to get the value of a column, called IsConfirmed (which is represented as a bit type column in the database) and convert it to bool.</p>
  
  <pre><code>bool isConfirmed = int.Parse(sqlDataReader["IsConfirmed"].ToString()) == 1;
  </code></pre>
  
  <p>I then get an FormatException error, stating that "Input string was not in a correct format.".</p>
  
  <p>I saw a similar question with an answer providing this code:</p>
  
  <pre><code>bool isConfirmed = sqlDataReader.GetBoolean(0);
  </code></pre>
  
  <p>But this won't work with my case, because I don't know the index of the IsConfirmed column and I don't want to know it. I want to use the column name.</p>