title: How do I retrieve the result of an ADO.NET SqlCommand?
body: <p>Ok either I'm really tired or really thick at the moment, but I can't seem to find the answer for this</p>
  
  <p>I'm using ASP.NET and I want to find the amount of rows in my table.</p>
  
  <p>I know this is the SQL code: <code>select count(*) from topics</code>, but how the HECK do I get that to display as a number?</p>
  
  <p>All I want to do is run that code and if it = 0 display one thing but if it's more than 0 display something else. Help please?</p>
  
  <p>This is what I have so far</p>
  
  <pre><code>string selectTopics = "select count(*) from topics";
  // Define the ADO.NET Objects
  SqlConnection con = new SqlConnection(connectionString);
  SqlCommand topiccmd = new SqlCommand(selectTopics, con);
  if (topiccmd == 0)
      {
          noTopics.Visible = true;
          topics.Visible = false;
      }
  </code></pre>
  
  <p>but I know I'm missing something seriously wrong. I've been searching for ages but can't find anything.</p>
  
  <p>PHP is so much easier. :)</p>