title: ExecuteScalar call throwing exception "Object reference not set to an instance of an object"
body: <p>When debugging the the following method in a unit test I get the following error </p>
  
  <blockquote>
    <p>Object reference not set to an instance of an object</p>
  </blockquote>
  
  <p>when hitting the following line</p>
  
  <pre><code>result = (int)validateDatabase.ExecuteScalar();
  </code></pre>
  
  <p>The method is</p>
  
  <pre><code>    public static Boolean Validate(string argument1, string argument2)
      {            
          int result = -1;
  
          using (var connection = new SqlConnection("connection string"))
          {
              SqlCommand validateDatabase = new SqlCommand("PROCEDURE NAME", connection);
              validateDatabase.CommandType = System.Data.CommandType.StoredProcedure;
              validateDatabase.Parameters.Add("@PARAMETER1", System.Data.SqlDbType.NVarChar).Value = argument1;
              validateDatabase.Parameters.Add("@PARAMETER2", System.Data.SqlDbType.NVarChar).Value = argument2; 
  
              try
              {
                  connection.Open();
                  result = (int)validateDatabase.ExecuteScalar();
              }
              catch (SqlException exception) { Trace.WriteLine("exception.Message); }
              finally { connection.Close(); }
          }
          return (int)result == 0 ? true : false; 
      }
  </code></pre>