DataSet.Merge where data being merge has less rows than the oringal source

  • Thread starter Thread starter Dan Hibbert
  • Start date Start date
D

Dan Hibbert

Hi,
I'm having a bit of difficulty with the merge command. The situation is:

I have a table of data with 15 rows. I've run some code to get some data
from SAP - I then convert the SAPtable to an ADO DataTable which has 14
rows. When I run the following:

CurrencyAdapter.fill(dsCurrency)
dsCurrency.Merge(dsSAPCurrency)

The number of rows is still 15. The row that I want to get rid of has a
rowstate of unchanged so when I call CurrencyAdapter.Update(dsCurrency), it
is not deleted.

Is there a method of merging data that would make the unwanted row have a
rowstate of deleted? Or have I gone about this the wrong way? I did think
of locking the table in a transaction, deleting all the data then running
Update so that only the records I've got from SAP will be added.

Any help much appreciated .

Dan
 
Hi Dan,

You are right - Merge only merges and won't delete rows.
You'll have to do it manually (a loop....)
 
Hi Miha,
Thanks for the info - that's what I did in the end - would have been
nice to find a funkier method!

Miha Markic said:
Hi Dan,

You are right - Merge only merges and won't delete rows.
You'll have to do it manually (a loop....)

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com

Dan Hibbert said:
Hi,
I'm having a bit of difficulty with the merge command. The situation
is:

I have a table of data with 15 rows. I've run some code to get some data
from SAP - I then convert the SAPtable to an ADO DataTable which has 14
rows. When I run the following:

CurrencyAdapter.fill(dsCurrency)
dsCurrency.Merge(dsSAPCurrency)

The number of rows is still 15. The row that I want to get rid of has a
rowstate of unchanged so when I call CurrencyAdapter.Update(dsCurrency),
it is not deleted.

Is there a method of merging data that would make the unwanted row have a
rowstate of deleted? Or have I gone about this the wrong way? I did
think of locking the table in a transaction, deleting all the data then
running Update so that only the records I've got from SAP will be added.

Any help much appreciated .

Dan
 
Back
Top