none
Wpf remove Constraint from datatable

    Question

  • 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

    Friday, February 15, 2013 8:08 PM

Answers

All replies