I have a non-typed dataset filled with data from user input (no database). There’s no primary key column (my data had no need for primary key so far)! Is there any way to avoid “brute force” if i want to check if new row user is trying to insert already exists in my DataTable? How should i perform that check?
I have a non-typed dataset filled with data from user input (no database). There’s
Share
You can manually create unique constraints for your DataTable:
For this example, you would get an exception (of type
ConstraintException) if you tried to add a row to the table where theCustomerIDandCompanyNamewere duplicates of another row with the sameCustomerIDandCompanyName.I would just let the
DataTablecheck these things for you internally – no point reinventing the wheel. As to how it does it (whether it is efficient or not), will have to be an exercise for you.