UniqueConstraint error: "These columns don't currently have unique values"

  • Thread starter Thread starter Timo
  • Start date Start date
T

Timo

I set up an alternate unique composite index in Access2000 using the
indexing dialog:

AltUniq: MyTable.ColumnA
MyTable.ColumnB

Primary: No
Unique: Yes
IgnoreNulls: No (NOTE: have also tried Yes here)

The columns are Text. ColumnA is required and does not allow zero-length
strings. ColumnB is not required and does allow zero-length strings.

This is equivalent to creating a unique index on (ColumnA, ColumnB).
Access doesn't complain, which means Access regards the column
combination as satisfying the uniquness test after scanning the data.
Access accepts the index when IgnoreNulls = No and when IgnoreNulls=Yes.

However, ADO.NET gives me the error in the subject line, namely that the
columns violate uniqueness. Googling, I've seen people reporting this
error when setting up relations.

Here's my code:

Dim ConstraintCols As DataColumn() ' for multi-column uniqueness
ConstraintCols = New DataColumn() {T.Columns("ColumnA"), _
T.Columns("ColumnB")}
Dim uc As UniqueConstraint = New UniqueConstraint("MyConstraint",
ConstraintColumns)
Dataset.Tables(MyTableName).Constraints.Add(uc)

Grateful for any tips/suggestions.
TIA
Timo
P.S. Cross-posted to Access in case someone there has helpful info on
the Access side of the issue.
 
Back
Top