title: Returning a single row
body: <p>I'm trying to return a single row from a database:</p>
  
  <pre><code>using (connection = new SqlConnection(ConfigurationManager.AppSettings["connection"]))
  {
      using (command = new SqlCommand(@"select top 1 col_1, col_2 from table1", connection))
      {
          connection.Open();
  
          using (reader = command.ExecuteReader())
          {
              reader.Read();
              return reader["col_1"];
          }
      }
  }
  </code></pre>
  
  <p>But I'm getting the following error message:</p>
  
  <blockquote>
    <p>Compiler Error Message: CS0266: Cannot implicitly convert type 'object' to 'string'. An explicit conversion exists (are you missing a
    cast?)<br>
    Line 90: return reader["col_1"];</p>
  </blockquote>
  
  <p>I'm sure I am making a really obvious mistake, but I can't seem to find any single row examples, all I examples I find are for multiple returned rows using a <code>while loop</code>.</p>