Re: Cloning A DataRow
- From: "Cor Ligthert[MVP]" <notmyfirstname@xxxxxxxxx>
- Date: Sun, 16 Mar 2008 11:48:53 +0100
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@xxxxxxxxxxxxxxxxScott,
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@xxxxxxxxxxxxxxxxxxxxxxxI 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
.
- Follow-Ups:
- Re: Cloning A DataRow
- From: Scott M.
- Re: Cloning A DataRow
- References:
- Cloning A DataRow
- From: Scott M.
- Re: Cloning A DataRow
- From: Scott M.
- Cloning A DataRow
- Prev by Date: BindingSource.Current is null on position change.
- Next by Date: Re: Cloning A DataRow
- Previous by thread: Re: Cloning A DataRow
- Next by thread: Re: Cloning A DataRow
- Index(es):
Relevant Pages
|