title: Unable to cast object of type 'System.DBNull' to type 'System.String`
body: <p>I got the above error in my app. Here is the original code</p>
  
  <pre><code>public string GetCustomerNumber(Guid id)
  {
       string accountNumber = 
            (string)DBSqlHelperFactory.ExecuteScalar(connectionStringSplendidmyApp, 
                            CommandType.StoredProcedure, 
                            "GetCustomerNumber", 
                            new SqlParameter("@id", id));
       return accountNumber.ToString();
   }
  </code></pre>
  
  <p>I replaced with</p>
  
  <pre><code>public string GetCustomerNumber(Guid id)
  {
     object accountNumber =  
            (object)DBSqlHelperFactory.ExecuteScalar(connectionStringSplendidCRM, 
                                  CommandType.StoredProcedure, 
                                  "spx_GetCustomerNumber", 
                                  new SqlParameter("@id", id));
      if (accountNumber is System.DBNull)
      {
         return string.Empty;
      }
      else
      {
         return accountNumber.ToString();
      }
  }
  </code></pre>
  
  <p>Is there a better way around this?</p>