Copying a datarow

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Supa Hoopsa

    #1

    Copying a datarow

    I am sure this must be REALLY simple, but I've spent the last 2 hours trying
    to failing to figure out how to copy a datarow from an existing table to a
    new table WITHOUT getting the following error:

    Run-time exception thrown : System.Argument Exception - This row already
    belongs to another table.

    I know the row I want to copy and so my code looks like this:

    Dim myTable As New DataTable
    Dim myDataRow As Data.DataRow = dsProjectsGroup .Tables("Projec ts").Rows(i)
    myTable.Rows.Ad d(myDataRow)

    any ideas what I am doing wrong?
  • Supa Hoopsa

    #2
    RE: Copying a datarow

    I knew it had to be easy:

    myTable.importr ow(dsProjectsGr oup.Tables("Pro jects").Rows(i) )


    "Supa Hoopsa" wrote:
    [color=blue]
    > I am sure this must be REALLY simple, but I've spent the last 2 hours trying
    > to failing to figure out how to copy a datarow from an existing table to a
    > new table WITHOUT getting the following error:
    >
    > Run-time exception thrown : System.Argument Exception - This row already
    > belongs to another table.
    >
    > I know the row I want to copy and so my code looks like this:
    >
    > Dim myTable As New DataTable
    > Dim myDataRow As Data.DataRow = dsProjectsGroup .Tables("Projec ts").Rows(i)
    > myTable.Rows.Ad d(myDataRow)
    >
    > any ideas what I am doing wrong?[/color]

    Comment

    Working...