title: C# 'select count' sql command incorrectly returns zero rows from sql server
body: <p>I'm trying to return the rowcount from a SQL Server table.  Multiple sources on the 'net show the below as being a workable method, but it continues to return '0 rows'.  When I use that query in management studio, it works fine and returns the rowcount correctly.  I've tried it just with the simple table name as well as the fully qualified one that management studio tends to like.</p>
  
  <pre><code>            using (SqlConnection cn = new SqlConnection())
              {
                  cn.ConnectionString = sqlConnectionString;
                  cn.Open();
  
                  SqlCommand commandRowCount = new SqlCommand("SELECT COUNT(*) FROM [LBSExplorer].[dbo].[myTable]", cn);
                  countStart = System.Convert.ToInt32(commandRowCount.ExecuteScalar());
                  Console.WriteLine("Starting row count: " + countStart.ToString());
              }
  </code></pre>
  
  <p>Any suggestions on what could be causing it?</p>