|
-
December 31st, 2008, 12:15 PM
#1
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.
-
December 31st, 2008, 08:51 PM
#2
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.
-
January 1st, 2009, 01:34 AM
#3
Re: Filling a DataTable by importing some rows from 2 other DataTables
 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.
-
January 2nd, 2009, 04:49 AM
#4
Re: Filling a DataTable by importing some rows from 2 other DataTables
 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|