Re: Cloning A DataRow



Scott,

Then you have to copy the values and not the references in that.

You can simple do that by using a for each loop through the DataColumns, the only problem is that you can use the datacolumn from the references table and have for the other one the DataColumn.Name (The string).

Cor

"Scott M." <smar@xxxxxxxxxxxxx> schreef in bericht news:OuFcsh3hIHA.4844@xxxxxxxxxxxxxxxxxxxxxxx
Thanks Cor, but this is not what I'm looking for.

I want to make a copy of the DataRow object (and thus the data in the DataRow), so that the copy can exist in a separate DataTable than the first one. I'm not talking about a second variable reference.


-Scott

"Cor Ligthert[MVP]" <notmyfirstname@xxxxxxxxx> wrote in message news:598B0B28-18B5-49DC-9DC2-A4C36A15FD76@xxxxxxxxxxxxxxxx
Scott,

Whatever you copy, then it is always a shalow copy of the copied one.

By instance this code (version 2008 type VB)

\\\
Dim scottsSet As New Scott
Dim scottsTable = scottsSet.DataTable1
Dim firstRow = scottsTable.NewDataTable1Row
firstRow.DataColumn1 = "One"
firstRow.DataColumn2 = "two"
scottsTable.AddDataTable1Row(firstRow)

Dim corsSet As New Scott
corsSet.Merge(scottsTable)
///

Here the scottsSet and the corsSet are in fact completely the same and reference to the same data. (a change in the corsSet is in fact the same as in the scottsSet).

This is because you are in fact only working with references. To add values to the datarows you have really to set the items to values.

I assume you knew this already however wanted it to be showed by somebody else.

Cor



"Scott M." <smar@xxxxxxxxxxxxx> schreef in bericht news:Oz3s%23KthIHA.2304@xxxxxxxxxxxxxxxxxxxxxxx
Hi Cor,

As I said the row I want to copy will be placed into another typed-dataset of the same type, so there will be no issuse with column mapping.

-Scott

"Cor Ligthert[MVP]" <notmyfirstname@xxxxxxxxx> wrote in message news:1CF300D0-058C-444E-9765-FC87CEB00C6E@xxxxxxxxxxxxxxxx
Scott,

It depends if it is for the same datatable or that you want to put it in an other datatable.

As you know is the datarow using the columns descriptions from the datatable, that is the reason that you never can copy whatever datarow to another table. (The datarow has even one property table, which tells to what tables it belongs (get its columns from)).

Be aware that with strongly typed datasets the merge is an important method, while it is in my idea with non typed ones mostly ignored.

Cor

"Scott M." <smar@xxxxxxxxxxxxx> schreef in bericht news:uttKc9rhIHA.5824@xxxxxxxxxxxxxxxxxxxxxxx
I need to copy an entire row of a typed DataSet so that I can place it into a different instance of the same type of typed DataSet. I don't see a clone or copy method on the DataRow. Do I have to create and populate the row manually?

-Scott








.



Relevant Pages

  • Re: Cloning A DataRow
    ... The problem that I'm facing is that this is a typed-dataset and some of the ... Then you have to copy the values and not the references in that. ... I want to make a copy of the DataRow object (and thus the data in the ... Dim scottsSet As New Scott ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Cloning A DataRow
    ... Then you have to copy the values and not the references in that. ... I want to make a copy of the DataRow object (and thus the data in the ... Dim scottsSet As New Scott ... Be aware that with strongly typed datasets the merge is an important ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Cloning A DataRow
    ... Dim scottsSet As New Scott ... As you know is the datarow using the columns descriptions from the datatable, that is the reason that you never can copy whatever datarow to another table. ... Be aware that with strongly typed datasets the merge is an important method, while it is in my idea with non typed ones mostly ignored. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: OT 9/11 Report
    ... Scott in Florida wrote: ... >>> What I DID find were many references indicating NO LINK between Iraq ... we all make mistakes (I could write a book about how to make ...
    (alt.autos.toyota)
  • Re: SemiOT Wikipedia and roads
    ... aren't all as ethical and unbiased as you think they are, Sherman. ... Scott M. Kozel Highway and Transportation History Websites ... it has an orange "this article has no references" flag at the top, ... "Nature" did a study which showed that Wikipedia on average actually ...
    (misc.transport.road)