title: ExecuteScalar returns null or DBNull (development or production server)
body: <p>I'm trying to add a column to an existing <code>DataRow</code> in C#. Afterwards the column will be filled with a single value from my database.</p>
  
  <p>DataRow dr already exists and column "COLNAME" also exists.<br>
  comTBP is my <code>SqlCommand</code>.</p>
  
  <pre><code>dr["COLNAME"] = Convert.ToInt32(comTBP.ExecuteScalar());
  </code></pre>
  
  <p>This all works fine if there is a value in my database and ExecuteScalar() can get that value. If I test this code on my development server (local) it also works if ExecuteScalar() return null or DBNull and the value of my new column is 0. But the problem appears if I deploy my code to the production server. If I do everything the same, with the same database it throws an Exception with a message that it can't convert DBNull to Int32.<br>
  My question is why does this error appear on the production server and not on my local development server?</p>