To make a DataRow object unique on multiple columns in C#, you can create a unique constraint on the DataTable that contains the DataRow.
Here is an example:
main.cs979 chars36 lines
In the example above, we create a DataTable with three columns (Column1, Column2, and Column3). We then create a unique constraint on Column1 and Column2. We add a DataRow to the table that violates the unique constraint (i.e. it has the same values for Column1 and Column2 as an existing row). Finally, we try to add another DataRow with the same values for Column1 and Column2, which throws a constraint violation exception.
gistlibby LogSnag