merging deltas

L

lc

Hi,

I have a bit of a mystery with merging updates into dataset. Here's what
I do (roughly):

DataSet dsDelta;

dsDelta = dsOriginal.GetChanges();
dsDelta = FunctionThatCallsAdaptersUpdates( dsDelta );
dsOriginal.Merge( dsDelta );

After merge, I get a very puzzling "Failed to enable constraints. One or
more rows contain vales violating non-null, unique, or foreign-key
constraints...".

This seem to happen only on one of 7 tables in the (typed) dataset. The
table has a primary key; integer; is not auto-increment; and with
respect to keys is no different than any other in the dataset. After the
failed merge I end up looking at two records with identical primary keys.

Am I missing anything in the process or could the dataset schema be
corrupted or... any idea would be truly appreciated!!

TIA.

lc
 
S

Sahil Malik [MVP]

I would recommend disabling the constraints before the merge, examining the
data and see what specific data causes your constraint to misfire.

Once you find out what specific constraint misfired, you'll be able to
figure out why exactly is the constraint misfiring. Merge behaves in more
ways than one. It's exact behavior depends on 2 main factors

a) What is being merged with what?
b) What are the schemas of the objects being merged.

Given that you would find out what specific data is causing the misfire, you
would be able to tweak the schema to make it work (unless the data is
corrupt).


- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
 
L

lc

Thanks Malik. So, to make it sure, the procedure I use is okay. The
problem seem to be related to dataset constraints, correct?

I'm still getting my feet wet with .NET and am not sure how do I go
about finding out what went wrong in detail. I looked at
DataSet.MergeFailed event but the damn thing won't ever fire. Where/how
would I peek into merge process?

Thanks a lot for your time.

lc
 
S

Sahil Malik [MVP]

lc,

I'd recommend to remove the constraints or simply use a plain vanilla
dataset for testing purposes. Than just do DataSet.WriteXml("c:\lc.xml") and
load up lc.xml in Internet Explorer to view the XML contents - thus your
dataset contents.

In there somewhere you will see a constraint violation.

Does your error message tell you which specific constraint misfired? (I
doubt, but worth a shot ;-)).

BTW, are you using a strongly typed dataset?

- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
----------------------------------------------------------------------------
---------------

lc said:
Thanks Malik. So, to make it sure, the procedure I use is okay. The
problem seem to be related to dataset constraints, correct?

I'm still getting my feet wet with .NET and am not sure how do I go
about finding out what went wrong in detail. I looked at
DataSet.MergeFailed event but the damn thing won't ever fire. Where/how
would I peek into merge process?

Thanks a lot for your time.

lc

I would recommend disabling the constraints before the merge, examining the
data and see what specific data causes your constraint to misfire.

Once you find out what specific constraint misfired, you'll be able to
figure out why exactly is the constraint misfiring. Merge behaves in more
ways than one. It's exact behavior depends on 2 main factors

a) What is being merged with what?
b) What are the schemas of the objects being merged.

Given that you would find out what specific data is causing the misfire, you
would be able to tweak the schema to make it work (unless the data is
corrupt).


- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
--------------------------------------------------------------------------
--
 
L

lc

This is just utterly weird. I just deleted all relations (lost a lot of
application functionality, though) and am still getting the same error.

Wait, there's more: then I deleted the xsd (and its files) from the
project; went back to data adapters and tried to create a new dataset
class by calling Generate Dataset on each of them. However, only the
last table generated would be added to the xsd. And why? It's because
each one wants to generate new table called Table and there's no way to
rename This is just too weird. And trust me, I did close and reopen
solution several times; restarted studio a few times.

Aaaaaaaaannywayzz, I got around all these things and recreated
everything I've had before and things - just works as expected. Weird
stuff, I tell ya.

I guess, problem solved but no clue why.

Either way, thanks a lot for your time.

lc
 

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