Quantcast
Viewing all articles
Browse latest Browse all 18858

Wpf remove Constraint from datatable

I have datatable created from MS Access database using DataAdapter.
for ex: adapter.Fill(result);

Issue is, MS Access datatable has Primary key. But i dont want to have that
primary key Constraint to my new datatable.

I tried below code to remove constraint but it's not working:

foreach (Constraint cnst in result.Constraints)
   {
      if (result.Constraints.CanRemove(cnst)) // it always returns false.
      {
         result.Constraints.Remove(cnst);
      }
   }

Error: Cannot remove unique constraint since it's the primary key of table Copy of Table1.

Please help me how would I delete constraint.

Thanks
Dee


Viewing all articles
Browse latest Browse all 18858

Trending Articles