Re: Merge is adding 2 records to the dataset
From: news.microsoft.com (v-hshah_at_microsoft.com)
Date: 02/23/05
- Next message: Atul: "Unrepresentable DateTime error using OLEDB data Provider"
- Previous message: Frans Bouma [C# MVP]: "Re: Data Access Components"
- In reply to: Miha Markic [MVP C#]: "Re: Merge is adding 2 records to the dataset"
- Next in thread: Miha Markic [MVP C#]: "Re: Merge is adding 2 records to the dataset"
- Reply: Miha Markic [MVP C#]: "Re: Merge is adding 2 records to the dataset"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 23 Feb 2005 05:26:38 -0500
What if i'm doing only 1 record update at a time.
Also my insert command also has a select statement which uses the @@Identity
to get the auto # assigned to the new row.
Are you saying I update the "dsOriginal" from "dsGetchanges" and then merge?
Then why merge at all ?
Do you have a code snippet I can use ? or any article/book you can point me
to.
Thanks.
HS
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:%23GtH%23IYGFHA.1084@tk2msftngp13.phx.gbl...
> Hi Hemang,
>
> Yes, this is how Merge works - it looks at primary key to find out whether
> row exists or not and it is not very Update friendly.
> In autoinc case it thinks that there is a new row since the primary keys
> differ.
> This is how I solve it:
> Before doing update I link same rows from original and getchanges dataset
> (I create an array of instances of a class that holds references to both
> rows)
> After update I manually refresh the primary key of original rows from the
> updated rows (first setting DataColumn.ReadOnly = false, refresh the value
> and reset ReadOnly).
> And then, I do the merge.
>
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & development
> www.rthand.com
> SLODUG - Slovene Developer Users Group www.codezone-si.info
>
> "Hemang Shah" <hemang@hemang.net> wrote in message
> news:e_SdnRDyw-vYMobfRVn-jg@rogers.com...
>> What im doing:
>>
>> Adding new record to my form.
>>
>> Creating a temp dataset "dsChanges" by using getchanges()
>>
>> dataadapter.update(dsChanges)
>>
>> Then I merge my original dataset dsOriginal.merge(dsChanges)
>>
>> But now my dataset has 2 records instead of 1,
>>
>> one with the auto id field = -1 and one with the autoid field as the one
>> retrived from the database.
>>
>> The database has only 1 record added though.(which is correct).
>>
>> Anyone got any inputs on this one ?
>>
>> Thanks
>>
>>
>
>
- Next message: Atul: "Unrepresentable DateTime error using OLEDB data Provider"
- Previous message: Frans Bouma [C# MVP]: "Re: Data Access Components"
- In reply to: Miha Markic [MVP C#]: "Re: Merge is adding 2 records to the dataset"
- Next in thread: Miha Markic [MVP C#]: "Re: Merge is adding 2 records to the dataset"
- Reply: Miha Markic [MVP C#]: "Re: Merge is adding 2 records to the dataset"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|