Using two datatables to create a new one

  • Thread starter Maziar Aflatoun
  • Start date
M

Maziar Aflatoun

Hi,

I have two datatables,

DataTable1
dtCurProducts.Columns.Add(new DataColumn("Id",
Type.GetType("System.String")));
dtCurProducts.Columns.Add(new DataColumn("ProductId",
Type.GetType("System.String")));
dtCurProducts.Columns.Add(new DataColumn("Quantity",
Type.GetType("System.String")));
dtCurProducts.Columns.Add(new DataColumn("FinalPrice",
Type.GetType("System.String")));


DataTable2
dtProducts.Columns.Add(new DataColumn("Id", Type.GetType("System.String")));
dtProducts.Columns.Add(new DataColumn("Name",
Type.GetType("System.String")));
dtProducts.Columns.Add(new DataColumn("ProductCode",
Type.GetType("System.String")));
dtProducts.Columns.Add(new DataColumn("DefaultPrice",
Type.GetType("System.String")));

DataTable2 contains a list of all of my products. DataTable1 contains the
Quantity and the FinalPrice. Now I like to create another DataTable or
expand DataTable1 as I'm creating it to include 3 additional fields taken
from DataTable2 so that my end result would be a DataTable containing
ProductId, Quantity, Name, ProductCode, DefaultPrice and FinalPrice
(Relationship between the 2 tables defined by
DataTable1.ProductId=DataTable2.Id

Can someone please tell me how I can accomplish this? Maybe as I'm creating
the contents of DataTable1 (Given I have DataTable2)

Thank you
Maziar A.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top