MrDave's (David Yack) WebLog

Dataset Errors and Finding Needles in a haystack...

System.ArgumentException: These columns don't currently have unique values.
   at System.Data.ConstraintCollection.AddUniqueConstraint(UniqueConstraint constraint)
   at System.Data.ConstraintCollection.Add(Constraint constraint)
   at System.Data.DataTable.set_PrimaryKey(DataColumn[] value)

Usually these are caused by not having a fully qualified key - but it sure would be nice to have a useful message generated when the error occurs because of the data

For Example:

System.ArgumentException: These columns don't currently have unique values. Row#20 Key Value=“ABC“
   at System.Data.ConstraintCollection.AddUniqueConstraint(UniqueConstraint constraint)
   at System.Data.ConstraintCollection.Add(Constraint constraint)
   at System.Data.DataTable.set_PrimaryKey(DataColumn[] value)

Comments

Fabrice said:

Maybe you do if you check GetColumnsInError()
# December 4, 2003 6:01 PM

Ravi Singh said:

Please Check the Orere of filling DataTables. Parent Table Should be filled prior to filling child table.

I got my problem solved this way

Thanks

Ravi
# February 12, 2004 9:56 AM

Exterior Shutters said:

I was having this issue with grandchildren when calling GetChildRows from an individual child datarow object.  However, the problem was fixed by setting createConstraints to False when adding the relation to the dataset object.

# January 26, 2008 7:43 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)