G
Guest
Hi,
I would like to ad Constraints to a database column, which only can have
unique values. The column can be empty only if the table is empty (no
records).
Im using the syntaxt:
pk = new DataColumn[1];
pk[0] = ds.Tables["table"].Columns["ID"];
ds.Tables["table"].Constraints.Add(new UniqueConstraint("ConstrName", pk[0]));
ds.Tables["table"].PrimaryKey = pk;
The problem is when the datatable is empty. I get an error message "the
column doesn't contain the unique value".
Is it possible to avoid this with an empty table?
Thanks,
Lubomir
I would like to ad Constraints to a database column, which only can have
unique values. The column can be empty only if the table is empty (no
records).
Im using the syntaxt:
pk = new DataColumn[1];
pk[0] = ds.Tables["table"].Columns["ID"];
ds.Tables["table"].Constraints.Add(new UniqueConstraint("ConstrName", pk[0]));
ds.Tables["table"].PrimaryKey = pk;
The problem is when the datatable is empty. I get an error message "the
column doesn't contain the unique value".
Is it possible to avoid this with an empty table?
Thanks,
Lubomir