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

Re: Cloning A DataRow by Cor

Cor
Sat Mar 15 13:55:56 CDT 2008

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@nospam.nospam> schreef in bericht
news:uttKc9rhIHA.5824@TK2MSFTNGP03.phx.gbl...
>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
>


Re: Cloning A DataRow by Scott

Scott
Sat Mar 15 14:30:21 CDT 2008

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@planet.nl> wrote in message
news:1CF300D0-058C-444E-9765-FC87CEB00C6E@microsoft.com...
> 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@nospam.nospam> schreef in bericht
> news:uttKc9rhIHA.5824@TK2MSFTNGP03.phx.gbl...
>>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
>>
>



Re: Cloning A DataRow by Cor

Cor
Sun Mar 16 05:48:53 CDT 2008

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@nospam.nospam> schreef in bericht
news:Oz3s%23KthIHA.2304@TK2MSFTNGP05.phx.gbl...
> 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@planet.nl> wrote in message
> news:1CF300D0-058C-444E-9765-FC87CEB00C6E@microsoft.com...
>> 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@nospam.nospam> schreef in bericht
>> news:uttKc9rhIHA.5824@TK2MSFTNGP03.phx.gbl...
>>>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
>>>
>>
>
>


Re: Cloning A DataRow by Scott

Scott
Sun Mar 16 10:16:21 CDT 2008

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@planet.nl> wrote in message
news:598B0B28-18B5-49DC-9DC2-A4C36A15FD76@microsoft.com...
> 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@nospam.nospam> schreef in bericht
> news:Oz3s%23KthIHA.2304@TK2MSFTNGP05.phx.gbl...
>> 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@planet.nl> wrote in message
>> news:1CF300D0-058C-444E-9765-FC87CEB00C6E@microsoft.com...
>>> 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@nospam.nospam> schreef in bericht
>>> news:uttKc9rhIHA.5824@TK2MSFTNGP03.phx.gbl...
>>>>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
>>>>
>>>
>>
>>
>



Re: Cloning A DataRow by Cor

Cor
Sun Mar 16 11:07:27 CDT 2008

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@nospam.nospam> schreef in bericht
news:OuFcsh3hIHA.4844@TK2MSFTNGP06.phx.gbl...
> 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@planet.nl> wrote in message
> news:598B0B28-18B5-49DC-9DC2-A4C36A15FD76@microsoft.com...
>> 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@nospam.nospam> schreef in bericht
>> news:Oz3s%23KthIHA.2304@TK2MSFTNGP05.phx.gbl...
>>> 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@planet.nl> wrote in message
>>> news:1CF300D0-058C-444E-9765-FC87CEB00C6E@microsoft.com...
>>>> 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@nospam.nospam> schreef in bericht
>>>> news:uttKc9rhIHA.5824@TK2MSFTNGP03.phx.gbl...
>>>>>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
>>>>>
>>>>
>>>
>>>
>>
>
>


Re: Cloning A DataRow by Scott

Scott
Sun Mar 16 13:53:59 CDT 2008

Yes Cor, I know how to copy the individual values out of a row. I was
hoping to not have to do that though.

Thanks,

Scott

"Cor Ligthert[MVP]" <notmyfirstname@planet.nl> wrote in message
news:71BF9C97-1B4B-45F4-94B7-1A678662DF80@microsoft.com...
> 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@nospam.nospam> schreef in bericht
> news:OuFcsh3hIHA.4844@TK2MSFTNGP06.phx.gbl...
>> 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@planet.nl> wrote in message
>> news:598B0B28-18B5-49DC-9DC2-A4C36A15FD76@microsoft.com...
>>> 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@nospam.nospam> schreef in bericht
>>> news:Oz3s%23KthIHA.2304@TK2MSFTNGP05.phx.gbl...
>>>> 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@planet.nl> wrote in message
>>>> news:1CF300D0-058C-444E-9765-FC87CEB00C6E@microsoft.com...
>>>>> 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@nospam.nospam> schreef in bericht
>>>>> news:uttKc9rhIHA.5824@TK2MSFTNGP03.phx.gbl...
>>>>>>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
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>



Re: Cloning A DataRow by Scott

Scott
Sun Mar 16 13:56:23 CDT 2008

To follow up on that....

The problem that I'm facing is that this is a typed-dataset and some of the
row data that will get copied from one typed-dataset to another (of the same
type) is read-only. So copying the data out of the first row is no problem,
but manually setting that value in the second typed-dataset is where the
problem is because I can't set the value of the read-only column.




"Cor Ligthert[MVP]" <notmyfirstname@planet.nl> wrote in message
news:71BF9C97-1B4B-45F4-94B7-1A678662DF80@microsoft.com...
> 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@nospam.nospam> schreef in bericht
> news:OuFcsh3hIHA.4844@TK2MSFTNGP06.phx.gbl...
>> 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@planet.nl> wrote in message
>> news:598B0B28-18B5-49DC-9DC2-A4C36A15FD76@microsoft.com...
>>> 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@nospam.nospam> schreef in bericht
>>> news:Oz3s%23KthIHA.2304@TK2MSFTNGP05.phx.gbl...
>>>> 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@planet.nl> wrote in message
>>>> news:1CF300D0-058C-444E-9765-FC87CEB00C6E@microsoft.com...
>>>>> 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@nospam.nospam> schreef in bericht
>>>>> news:uttKc9rhIHA.5824@TK2MSFTNGP03.phx.gbl...
>>>>>>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
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>



Re: Cloning A DataRow by Cor

Cor
Mon Mar 17 00:12:13 CDT 2008

Scott,

As I understand you well then that are fields like auto identifiers (and
timestamps) or fields that have to be DBNull.Value.

I simply do that by skipping those by testing them in the loop.

Cor


RE: Cloning A DataRow by v-wywang

v-wywang
Mon Mar 17 03:10:37 CDT 2008

Thanks for Cor's prompt reply.

Hello Scoot,

Have you tried with DataTable.ImportRow API? This way could copy datarow
into another table (of the same schema), even though some filed are
read-only.
For example:

DataSet1 ds1 = new DataSet1();
DataSet1TableAdapters.Table_1TableAdapter tta = new
ConsoleApplication83.DataSet1TableAdapters.Table_1TableAdapter();
tta.Fill(ds1.Table_1);

DataSet1 ds2 = new DataSet1();
foreach (DataSet1.Table_1Row tr in ds1.Table_1.Rows)
ds2.Table_1.ImportRow(tr);

Hope this helps, please feel free to let us know if there is anything
unclear. We are glad to assist you.
Best regards,
Wen Yuan

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Re: Cloning A DataRow by Scott

Scott
Mon Mar 17 08:02:56 CDT 2008

No the field in the second DataSet should have the same value as the field
in the first DataSet, not DBNull.

Thanks anyway, Cor.

"Cor Ligthert[MVP]" <notmyfirstname@planet.nl> wrote in message
news:CC1DB2F6-4788-4407-8BB4-03EBFD8360E3@microsoft.com...
> Scott,
>
> As I understand you well then that are fields like auto identifiers (and
> timestamps) or fields that have to be DBNull.Value.
>
> I simply do that by skipping those by testing them in the loop.
>
> Cor



Re: Cloning A DataRow by Scott

Scott
Mon Mar 17 08:03:49 CDT 2008

Hi Wen,

This looks like what I'm after - I'll give it a shot.

Thanks,

Scott

""Wen Yuan Wang [MSFT]"" <v-wywang@online.microsoft.com> wrote in message
news:wXeplZAiIHA.360@TK2MSFTNGHUB02.phx.gbl...
> Thanks for Cor's prompt reply.
>
> Hello Scoot,
>
> Have you tried with DataTable.ImportRow API? This way could copy datarow
> into another table (of the same schema), even though some filed are
> read-only.
> For example:
>
> DataSet1 ds1 = new DataSet1();
> DataSet1TableAdapters.Table_1TableAdapter tta = new
> ConsoleApplication83.DataSet1TableAdapters.Table_1TableAdapter();
> tta.Fill(ds1.Table_1);
>
> DataSet1 ds2 = new DataSet1();
> foreach (DataSet1.Table_1Row tr in ds1.Table_1.Rows)
> ds2.Table_1.ImportRow(tr);
>
> Hope this helps, please feel free to let us know if there is anything
> unclear. We are glad to assist you.
> Best regards,
> Wen Yuan
>
> Delighting our customers is our #1 priority. We welcome your comments and
> suggestions about how we can improve the support we provide to you. Please
> feel free to let my manager know what you think of the level of service
> provided. You can send feedback directly to my manager at:
> msdnmg@microsoft.com.
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx.
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>



Re: Cloning A DataRow by v-wywang

v-wywang
Tue Mar 18 03:18:10 CDT 2008


You are welcome, Scott.
Feel free to let us know if you face any further issue.. We are glad to
assist you.

Have a great day,
Best regards,
Wen Yuan
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.