title: Object cannot be cast from DBNull to other types. Error when a null value is read by the Reader
body: <pre><code>int topID = 0;
  string TopIDQuery = "Select TopID from tbl_Organisation where OrganisationID=@OrgID";
  
  paramet[0] = new MySqlParameter("@OrgID", MySqlDbType.Int32);
  paramet[0].Value = OrgID;
  
  reader = server.ExecuteReader(CommandType.Text, TopIDQuery, paramet);
  
  while (reader.Read())
  {
      topID = Convert.ToInt32(reader["TopID"]);
  }
  
  reader.Close();
  </code></pre>
  
  <p>I am reading the <code>topID</code> from the table, when the <code>TopID</code> is null I want to leave the <code>topID</code> as 0, but since it is null it is throwing a error, how can I handle this error when the <code>topID</code> is null</p>