title: Using the SQL Command object, how can you check to see if the result set is empty?
body: <p>Using the ExecuteScalar method in the SQL Command object, how can you check to see if the result set is empty?  I am using ASP.net, C#, and MS SQL 2008.  Right now when I run the following code the Response.Write returns a <b>0</b> when the resultset is empty.  But I would like to differentiate between <b>0</b> and empty resultsets because there are actual <b>0</b> values in my database.</p>
  
  <p>Here is the current code behind:</p>
  
  <pre><code>cmd = new SqlCommand("usp_test", cn);
  cmd.CommandType = CommandType.StoredProcedure;
  
  cn.Open();
  TestOuput = Convert.ToInt32(cmd.ExecuteScalar());
  cn.Close();
  
  Response.Write(TestOutput);
  </code></pre>
  
  <p>Thank you.</p>