title: How to handle DBnull when serializing DataSets and DataTables to JSON using JSON.NET
body: <p>I get the following error:</p>
  
  <blockquote>
    <p>"StrongTypingException - The value for column '{ColumnName}' in table '{TableName}' is DBNull."</p>
  </blockquote>
  
  <p>when I try to serialize an DataTable with some null values to JSON using JSON.NET.</p>
  
  <p>This is the code: </p>
  
  <pre><code>var dataSet= new DsGameInformatie();
  var adapter = new GameTableAdapter();
  adapter.FillByGameCategoryID(dataSet.Games, 1);
  var settings = new JsonSerializerSettings 
  { 
      NullValueHandling = NullValueHandling.Ignore, 
      MissingMemberHandling = MissingMemberHandling.Ignore, 
      ObjectCreationHandling = ObjectCreationHandling.Replace, 
      ReferenceLoopHandling = ReferenceLoopHandling.Ignore, 
      DefaultValueHandling = DefaultValueHandling.Ignore
  };
  
  return JsonConvert.SerializeObject(dataSet.Games, Formatting.None, settings);
  </code></pre>
  
  <p>Obviously I am doing something wrong. Am I missing something? How do I handle those DBNull values so that I don't get exceptions?</p>