在wpf中选择distinct的问题

时间:2012-10-03 13:25:11

标签: wpf database

我有一个WPF应用程序,当我运行Select distinct query时,我收到错误

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

.cs代码:

            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();

和查询

Select DISTINCT Category from Parts

1 个答案:

答案 0 :(得分:0)

我认为这可能与您的数据表有关,请检查您的xsd文件,特别是Parts TableAdapter