none
DataRelation b/n two sheets of Excel RRS feed

  • Question

  • Hi

    I have Two Excel Sheets.I have taken them in two DataTables

    I dont have same column in both datatables to create a relation.

    how do i populate the data of both DataTables into one

    Monday, April 9, 2012 5:18 AM

Answers

  • Hi I'MKan,

    Welcome to MSDN Forum.

    You can use Merge method to populate the data of both DataTables into one.

    If you have two datatables like table1 (col1 string), table2(col2 int), after executing "table1.Merge(table2)", the table1 will be table1(col1 string, col2 int). If the data is in table1, col2 will be null in the new table.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, April 10, 2012 3:01 AM
    Moderator

All replies

  • Hi I'MKan,

    Welcome to MSDN Forum.

    You can use Merge method to populate the data of both DataTables into one.

    If you have two datatables like table1 (col1 string), table2(col2 int), after executing "table1.Merge(table2)", the table1 will be table1(col1 string, col2 int). If the data is in table1, col2 will be null in the new table.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, April 10, 2012 3:01 AM
    Moderator
  • I don't know if that is the case but first put your two tables in a DataSet in Pseudo code to do it for all possible program languages which you use

    var ds = new DataSet
    ds.Add(MyTable1)
    ds.Add(MyTable2)

    Now you can add a Relation to the DataTables like in this link.

    http://msdn.microsoft.com/en-US/library/ay82azad(v=vs.100).aspx

    Very easy like you see and the column names don't have to be the same


    Success
    Cor

    Tuesday, April 10, 2012 5:06 AM