Click here to Skip to main content
14,299,779 members
Rate this:
Please Sign up or sign in to vote.
See more:
i have two datatables in dataset ds.
in table[0] i have columns mnth, amount,month
it looks a like
mnth   amount1  month
 9      1500    sep
10     1700    oct
11     2200    nov

and in table[1] i have columns mnth,amount
it looks a like
mnth   amount2
4       1000 
7       1500
9       800

now i want to merge tables and want to diplay such like this
month amount1  amount2    
4               1000
7               1500
9       1500     800
10      1700
11      2200


here both table's amount is irrelevant.. i want that both the amount should display month wise.. if both tables have amount in 9th month then there should be only one row..

i tried merge() function but it didn't worked.
plz help me out..
Posted
Updated 30-Jan-12 2:48am
v2
Comments
Anuja Pawar Indore 30-Jan-12 8:48am
   
formatting done
Rate this:
Please Sign up or sign in to vote.

Solution 1

   
Comments
Amir Mahfoozi 30-Jan-12 5:47am
   
+5
uspatel 30-Jan-12 5:48am
   
Thanks Amir....
Rate this:
Please Sign up or sign in to vote.

Solution 2

Try
dt.Merge()


Thanks
--RA
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

DataTable.Merge is not the right method, because merge processes data on row base. Instead of merge use LINQ if possible:

http://stackoverflow.com/questions/656013/linq-join-2-datatables-wildcard[^]
   
Comments
Member 8589824 30-Jan-12 4:56am
   
okay.. but how can i join tables in c#?? this ans is for linq

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100