Adding DataTable Rows To another DataTable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • J. Babe

    #1

    Adding DataTable Rows To another DataTable

    I was wondering how to add the first 20 rows from one datatable to
    another datatable without getting the error:
    This row already belongs to another table
  • Kevin Spencer

    #2
    Re: Adding DataTable Rows To another DataTable

    You need to "clone" the DataRow for the other table. DataRow doesn't
    implement ICloneable, so you will need to create a loop that creates a new
    row in the second DataTable, and copies the data contained in the columns of
    the first DataTables row to the new row created for the second DataTable,
    and then adds the new DataRow to the Rows Collection of the second
    DataTable.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    All hotels in Benidorm. The best selection of Benidorm hotels with reviews and maps. Book in advance and save.

    Neither a follower nor a lender be.

    "J. Babe" <babe_jt@hotmai l.com> wrote in message
    news:8b32873e.0 308150824.10352 ba2@posting.goo gle.com...[color=blue]
    > I was wondering how to add the first 20 rows from one datatable to
    > another datatable without getting the error:
    > This row already belongs to another table[/color]


    Comment

    Working...