How do I copy one dataset table to another dataset table?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Top Gun

    How do I copy one dataset table to another dataset table?

    Is there an easy way to do this?


  • William Ryan eMVP

    #2
    Re: How do I copy one dataset table to another dataset table?

    Keeping in mind that datatables are Reference types and the copy is simply
    a copy of the reference (ie any changes you make to the copy will be
    reflected in the original), this should work for you:

    Dim dt As New DataTable

    Dim dt2 As New DataTable

    Dim ds1 As New DataSet

    Dim ds2 As New DataSet

    ds1.Tables.Add( dt)

    dt2 = dt.Copy()

    ds2.Tables.Add( dt2)



    However, you can make a deep copy wherin you create a new table and set each
    value of the new field to the value of the sourdce...

    "Top Gun" <nfr@nospam.com > wrote in message
    news:OYY0rQO8DH A.3804@tk2msftn gp13.phx.gbl...[color=blue]
    > Is there an easy way to do this?
    >
    >[/color]


    Comment

    • Cor

      #3
      Re: How do I copy one dataset table to another dataset table?

      Hi Bill are you sure of that?
      [color=blue]
      > Keeping in mind that datatables are Reference types and the copy is simply
      > a copy of the reference (ie any changes you make to the copy will be
      > reflected in the original), this should work for you:[/color]

      Datatable.copy
      A new DataTable with the same structure (table schemas and constraints) and
      data as this DataTable.

      What you say is as far as I know.
      DataTable Dt;
      Dt = DtOld;

      But maybe I am wrong?

      :-)

      Cor


      Comment

      Working...