Filling a DataTable by importing some rows from 2 other DataTables
I’m filling a DataTable ‘C’ by importing some rows from 2 other DataTables ‘A’ and ‘B’ with the same structure.
The problem is that there is a unique column ‘id’ defined in the table, so it happens that I am trying to import 2 rows with the same ‘id’ value, and of-course I get a
System.Data.ConstraintException saying "Column 'id' is constrained to be unique. Value '0' is already present."
Is there a way to avoid this?
I can create a new row in table ‘C’ and copy each column’s value from the other table’s row, except the value of the unique column, but I wanted to use ImportRow to avoid this.
Re: Filling a DataTable by importing some rows from 2 other DataTables
Assign new unique id's to the columns in question, before importing them. Otherwise I think your only option is to add the rows manually to your table.
Re: Filling a DataTable by importing some rows from 2 other DataTables
Quote:
Originally Posted by
Traps
Assign new unique id's to the columns in question, before importing them. Otherwise I think your only option is to add the rows manually to your table.
Agreed.
Re: Filling a DataTable by importing some rows from 2 other DataTables
Quote:
Originally Posted by
Traps
Assign new unique id's to the columns in question, before importing them. Otherwise I think your only option is to add the rows manually to your table.
I don't want to change the original tables, because they are connected to other tables. So, I guess I'll have to add new rows manually like you suuggested.
Thanks.