Clone DataRow

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Doug Bell

    Clone DataRow


    Hi,
    I am trying to clone a DataRow (see below) but I have a syntax error
    refering to the implicit conversion from object to datarow.

    How can I convert the object into a datarow without itterating through the
    elements?

    Thanks

    Doug
    Dim dr, drNew As DataRow

    'Add Row 0 with Manufactured Product details

    dr = dtOrderDetails. Rows(0)

    drNew = dtOrderDetails. NewRow

    drNew.ItemArray = dr.ItemArray.Cl one


  • Cor Ligthert [MVP]

    #2
    Re: Clone DataRow

    Doug

    To deepcopy a datarow you need the schema which is in the datatable.

    Therefore I think that the most simple methods are to use or the importrow
    or the loaddatarow from that.



    A clone is only a shallow copy, which means that it copies the references to
    the original object.

    I hope this helps,

    Cor


    Comment

    • Doug Bell

      #3
      Re: Clone DataRow

      Thanks Cor,

      I was just about to post that I had a solution:
      Dim dt As DataTable

      Dim drNew As DataRow

      'Add Row 0 with Manufactred Product details

      dt = dtOrderDetails. Clone

      drNew = dtOrderDetails. Rows(0)

      dt.ImportRow(dr New)

      "Cor Ligthert [MVP]" <notmyfirstname @planet.nl> wrote in message
      news:%23hZKBvUq FHA.272@TK2MSFT NGP15.phx.gbl.. .[color=blue]
      > Doug
      >
      > To deepcopy a datarow you need the schema which is in the datatable.
      >
      > Therefore I think that the most simple methods are to use or the importrow
      > or the loaddatarow from that.
      >
      >[/color]
      http://msdn.microsoft.com/library/de...mberstopic.asp[color=blue]
      >
      > A clone is only a shallow copy, which means that it copies the references[/color]
      to[color=blue]
      > the original object.
      >
      > I hope this helps,
      >
      > Cor
      >
      >[/color]


      Comment

      Working...