title: How do I remove a datatable from a dataset (has a bunch of relationships)
body: <p>I am attempting to remove a datatable that was loaded into a dataset, and has been related.
  Here is the code I attempted.</p>
  
  <pre><code>domain.EnforceConstraints = false;
  if (domain.Tables["TABLE_NAME"] != null) 
  { 
      domain.Tables["TABLE_NAME"].ChildRelations.Clear(); 
      domain.Tables["TABLE_NAME"].ParentRelations.Clear(); 
      domain.Tables.Remove("TABLE_NAME"); 
  }
  domain.EnforceConstraints = true;
  </code></pre>
  
  <p>This throws an exception at the point of removing the table, due to a foreign-key constraint existing.  Unfortunately, the way the logic is I have no idea what the name of the constraint is [so I cannot hard code it].</p>
  
  <p>Is there away to accomplish this in an easier fashion, or can I get some suggestions as to how to locate and remove the constraint that is causing my issue.</p>
  
  <p>Thanks in advance, Steve</p>
  
  <p>--------------------------ANSWER------------------------</p>
  
  <p>I wasn't allowed to answer my own question so here is the solution I came up with.
  This code snippet now works for me.  I had to travel the relation to the other table and remove the constraint from there.</p>
  
  <pre><code>    if (domain.Tables["TABLE_NAME"] != null) 
      {
  
          for (int f = domain.Tables["TABLE_NAME"].ChildRelations.Count -1; f &gt;=0; f--)
          {
              domain.Tables["TABLE_NAME"].ChildRelations[f].ChildTable.Constraints.Remove(domain.Tables["TABLE_NAME"].ChildRelations[f].RelationName);
              domain.Tables["TABLE_NAME"].ChildRelations.RemoveAt(f);
          }
          domain.Tables["TABLE_NAME"].ChildRelations.Clear();
          domain.Tables["TABLE_NAME"].ParentRelations.Clear();
          domain.Tables["TABLE_NAME"].Constraints.Clear();
          domain.Tables.Remove("TABLE_NAME"); 
      }
  </code></pre>