Link to home
Start Free TrialLog in
Avatar of jdhackett
jdhackettFlag for Ireland

asked on

Create new Datatable from two linked datatables

I have two Datatables, dtRenewals and dtAgents. There is a field in each called AgentCode.
I'd like to create another table, dtRenewals_WithAgents, which would only contain the renewals that have an AgentCode that is in dtAgents.
How would I do this?
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

You can loop through dtAgents, find associated rows from dtrenewals and add to a new datatable.
Avatar of jdhackett


@srosebabu - those links are for merging two different tables. I don't want to merge the tables, I just want the rows from dtRenewals where the Agent is in dtAgents.
can you provide some sample data for the both data-tables with the required merged data sample?
Sample for dtRenewals:
PolicyRef = TEST09
AgentCode = ARC1
IssueDate = 31/04/13

PolicyRef = TEST10
AgentCode = ""
IssueDate = 31/04/13

PolicyRef = TEST11
AgentCode = BAR
IssueDate = 31/04/13

Sample for dtAgents:
AgentCode = ARC1
AgentName = Arch Insurances

AgentCode = ZAP
AgentName = Zap Insurances

In this example, I would only like the row for TEST09.
Avatar of Rose Babu
Rose Babu
Flag of India image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Very neat, thanks.