How to define a null-ignoring unique constraint
-
Hi. Is there a "ignore null's" property, or a way to implement it, in the Constraint or the UniqueConstraint of a DataTable? I have in the server (postgres 8.1.4) a field with a unique contraint, and this constraint can ignore nulls. How can i define such a thing in ADO.NET? Thanks.
-
Hi. Is there a "ignore null's" property, or a way to implement it, in the Constraint or the UniqueConstraint of a DataTable? I have in the server (postgres 8.1.4) a field with a unique contraint, and this constraint can ignore nulls. How can i define such a thing in ADO.NET? Thanks.
If the field allows null then you can have a unique key constraint on it. BTW: aggregate functions ignore NULLs by design.
Farhan Noor Qureshi
-
If the field allows null then you can have a unique key constraint on it. BTW: aggregate functions ignore NULLs by design.
Farhan Noor Qureshi
no... I have a UniqueConstraint on a field called 'cve_unidad', this field has .AllowDBNull = true, and i put DefaultValue = null in this field, but, there is still a the problem... when i put two rows in then datagrid, the second null value raises the error message: "Value Column 'cve_unidad' is constrained to be unique. Value '' is already present. Do you want to correct this value?" this is a example: cve_unidad | nom_unidad (null) | 'un nombre' <-- here is ok (null) | 'another nombre' <-- here raises the "already present" error This is an "autonumeric-like" scenario, i want to send some values at once, then clear an refill the datagrid with the data (with de autonumeric updated). I don't want to use the .AutoIncrement properte beacuse the value displayed will not neccesary equals the autonumeric value in the database. thanks