title: Handling ExecuteScalar() when no results are returned
body: <p>I am using the following SQL query and the <code>ExecuteScalar()</code> method to fetch data from an Oracle database:</p>
  
  <pre><code>sql = "select username from usermst where userid=2"
  string getusername = command.ExecuteScalar();
  </code></pre>
  
  <p>It is showing me this error message:</p>
  
  <blockquote>
    <p><em>System.NullReferenceException: Object reference not set to an instance of an object</em></p>
  </blockquote>
  
  <p>This error occurs when there is no row in the database table for <code>userid=2</code>.<br/>
  How should I handle this situation?</p>