Click here to Skip to main content
15,888,169 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have two differnt DataTable
FirstTable have morethen 100 columns
second table have morethan 100 columns.both table have same column ID

i want to merge two datatable rows into single
Posted

I think you better start by adding relationship first. If you have primary key ID in table1 and you can add ID column in Table 2 with the relevant ID.

Then you can use DataTable.Merge method directly.
 
Share this answer
 
 
Share this answer
 
Comments
ayubmytheen 29-Apr-14 13:00pm    
i tried above suggestion i am getting a error like
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
Look at the error message. Either schema of tables is not same or some row contains null or duplicate values.

Otherwise read the below which is in MSDN link I gave you.

"During a merge, constraints are disabled. If any constraints cannot be enabled at the end of merge, a ConstraintException is generated and the merged data is retained while the constraints are disabled. In this case, the EnforceConstraints property is set to false, and all rows that are invalid are marked in error. The errors must be resolved before attempting to reset the EnforceConstraints property to true."
Table A Table B
Column1 column2 Column1 Column3
1 A 1 D
3 F 3 H

i want result table like this

Column1 column2 Column3
1 A D
3 F H

any body can help me to resolve the issue....
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900