Dataset Merge question

C

Coaster

I've been tooling around with dataset merge to create a sync between 2
databases, lets call them A and B and I'm trying to sync A into B.

On the first round B is empty and B.Merge(A) results in B getting all 100
rows from A. All rows have rowstate unchanged which I would think they would
all be in the new state. From this GetChanges returns Null.

Just to make sure everytinhg works ok I force loaded all 100 rows into B and
tried this test again. I made 1 row change to A before the merge and as a
result GetChanges after B.Merge(A) does return that 1 row. I'm just confused
on why the first round results in no changes. Can someone enlighten me?

thank you.
 
C

Coaster

here some more disappointing news after I forced the data load into the B
table and tried to merge newer copy of an A table into B the merge is still
returning null
I even set the primary keys in case they were lost as some other postings
had suggested.

Here's some code, fooUpdates is always null and I can clearly see the data
has changed thru the visualizer.

Database localFooDb = FooConstants.LocalFooDatabase;
Database liveFooDb = FooConstants.LiveFooDatabase;
const bool isTodays = true;

FooDataTotals localFooDataTotals =
FooDatabase.RetrieveFooData(localFooDb,isTodays, pick);
DataColumn dc1 = localFooDataTotals._FooDataTotals.fooIdColumn;
localFooDataTotals._FooDataTotals.PrimaryKey[0] = dc1;

FooDataTotals liveFooDataTotals = FooDatabase.RetrieveFooData(liveFooDb,
isTodays, pick);
DataColumn dc = liveFooDataTotals._FooDataTotals.fooIdColumn;
liveFooDataTotals._FooDataTotals.PrimaryKey[0] = dc;


if (liveFooDataTotals._FooDataTotals.Rows.Count == 0)
{
InitializedTodaysFooData(liveFooDb, pick, localFooDataTotals);
}
else
{
liveFooDataTotals.Merge(localFooDataTotals);
var fooUpdates = (FooDataTotals) liveFooDataTotals.GetChanges();
if (fooUpdates != null)
{
foreach (FooDataTotals.FooDataTotalsRow dr in
liveFooDataTotals._FooDataTotals.Rows)
{
if (dr.RowState == DataRowState.Modified)
{
FooDatabase.FooDataTodaysTopXPercentTotalsUpdate(liveFooDb,
pick, dr.fooId, dr.foo, dr.Total);
}
else if (dr.RowState == DataRowState.Added)
{
FooDatabase.FooDataTodaysTopXPercentTotalsInsert(liveFooDb,
pick, dr.fooId, dr.foo, dr.Total);
}
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top