title: C#/Oracle10g = null vs DBNull.Value vs String.Empty
body: <p>I'm making my first forays into Accessing Oracle from C#. I've discovered that that Oracle doesn't like <code>VarChar</code> parameters to have value of <code>null</code> (C#). I would have hoped that there would be some implicit conversion, but I appreciate the difference.</p>
  
  <p>So I need to trap these null values and supply <code>DBNull.Value</code> instead, surely? The most obvious method was to use the coalesce operator <code>??</code>:</p>
  
  <pre><code>param myParm = myObject.MyProperty ?? DBNull.Value;
  </code></pre>
  
  <p>Except it doesn't accept a value of <code>System.DBNull</code>... so I have to use:</p>
  
  <pre><code>param myParm = myObject.MyProperty ?? DBNull.Value.ToString();
  </code></pre>
  
  <p>...which is surely the same as:</p>
  
  <pre><code>param myParm = myObject.MyProperty ?? String.Empty;
  </code></pre>
  
  <p>..which also works.  </p>
  
  <p>But I always understood that according to ANSI SQL rules, an empty string ("") != a NULL value... yet it appears to be in Oracle. </p>
  
  <p>Anyway, my question is, what is the best, practical or theoretical, way to handle the case of null string values? Is there a slick alternative that I haven't identified? Or is this just another idiosyncrasy of Oracle that we just accept?</p>