title: this method or property cannot be called on null values. data is null
body: <p>When I call the function I receive an error that says <code>data is null. This method or property cannot be called on null values.</code> </p>
  
  <p>I believe the error exists at this line 
      <code>Error = id = rd.GetString(0);</code></p>
  
  <p>The code I am using is below</p>
  
  <pre><code>public string MaxId()
  {
     string id="";
     con.Open();
     string sql = "SELECT MAX(CustID) FROM Customer";
     SqlCommand cmd = new SqlCommand(sql,con);
     SqlDataReader rd = cmd.ExecuteReader();
     while(rd.Read())
     {
        id = rd.GetString(0);
     }
     con.Close();
     return id;
  }
  </code></pre>
  
  <p>How do I get a string from the DataReader that may be null?</p>