Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Joining DataTables ?

Status
Not open for further replies.

meinhunna

Programmer
Jul 31, 2004
118
0
0
AU
Is there anyway of Joining two or more DataTable with similar structure?

I have three DataTables with following structures

Data, AmountB/F, Repayments, InterestCharged and AmountC/F

i want to join these tables on the basis of Date. I don't want three rows for each date, i want the values to be added for similar dates.

thanx
 
How about something like this...

SELECT Date, AmountB/F, Repayments, InterestCharged, AmountC/F
FROM table1
INNER JOIN table2 ON table1.Date = table2.Date
INNER JOIN table3 ON table2.Date = table3.Date

Not sure what your table names were, so I used table1, table2 and table3
 
Well I am talking in terms of DataTable object in .NET Framework, not Database tables.
 
You can use the DataRelation class.

Something like this-

'Create a new DataRelation
Dim rel As New DataRelation(strRelationName, dsDataSet.Tables("Table1")).Columns("Primary Key"), dsDataSet.Tables("Table2").Columns("Foreign Key"), False)

'Add the Relation to the DataSet
dsDataSet.Relations.Add(rel)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top