0

I have a WPF application and when I run Select distinct query I am getting an error as

Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

.cs code:

            Saman.DatabaseDataSet databaseDataSet = ((Saman.DatabaseDataSet)(this.FindResource("databaseDataSet")));
            // Load data into the table Employee. You can modify this code as needed.
            Saman.DatabaseDataSetTableAdapters.PartsTableAdapter databaseDataSetPartsTableAdapter = new Saman.DatabaseDataSetTableAdapters.PartsTableAdapter();
            databaseDataSetPartsTableAdapter.FillBy(databaseDataSet.Parts);

            System.Windows.Data.CollectionViewSource partsViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("partsViewSource")));
            partsViewSource.View.MoveCurrentToFirst();

and query is

Select DISTINCT Category from Parts
Tanuj Wadhwa
  • 2,025
  • 9
  • 35
  • 57
  • Take a look here, maybe it would help to get out of your issue: http://stackoverflow.com/questions/7026566/failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null – michele Oct 03 '12 at 13:43

1 Answers1

0

I think that this may have something to do with your datatable, please check your xsd file in particular the Parts TableAdapter

Krunal Savani
  • 129
  • 1
  • 2