Better to pass dataSet1 or just GetChanges() to Update()?

  • Thread starter Thread starter Eric Harmon
  • Start date Start date
E

Eric Harmon

Hi again, and please pardon the silly question - new to ADO.NET... :-)

When I call the DataAdapter's Update() method, am I better off passing the
entire dataset, or call GetChanges() first? Is there a performance
difference either way, either when

A) all parts of the application are on the same machine
B) a middle tier is set up on a remote machine. It seems to me that in this
case it's better to just pass the changes (less data to serialize), but I
want to make sure I'm correct in my thinking.

Thanks!

-Eric
 
say you fetched 100 records and updated 10... which would be faster sending
the 10 updated records for database update or the entire lot ?
 
HD,

Thanks, but that's a pretty sarcastic answer, and of course I've considered
the obvious. Of course, passing a pointer to the dataset object to a method
doesn't pass the data itself, and I wasn't sure exactly where in the process
the middle tier comes in in ADO.NET. So I wasn't 100% sure if only the
changes would get passed across the wire regardless of what I did in the
client app. That's why I was asking.

I received the answer I needed from your post, but would have appreciated a
more courteous reply. But thanks anyway...

-Eric
 
well sorry didnt mean to sound sarcastic... was just making you ask yourself
the question...
yes there are situations when all the records need to be updated.. but whats
the possibility ?
occasional at the max...
its just an extra call to get the changes and for whats its worth... 9 of 10
times it will end up being faster..
again sorry didnt mean to hurt your feelings..
 
Hi Eric,

The question is more difficult than you might think. I have had occasion to
call getchanges and run into a memory error when the amount was very large
(say, 650,000 - happens when doing a data conversion from large dbase files
to a datatable). So, regardless of the obvious, be aware that there are
times that I have had to call the entire dataadapter update (and I didn't
get an 'out of memory' error there) instead of getchanges. And, by the way,
I have a gig of random access memory, so it wasn't the fault of my
development environment.

HTH,

Bernie Yaeger
 
Eric,
In addition to the other comments.

From your post I cannot tell: Is the original DataSet is the same AppDomain,
a different AppDomain same machine, or a different AppDomain different
machine?

As where I was Updating, changes the approach I would take. Remember that
Update only looks at changed rows, so calling GetChanges is not always
needed...

For same AppDomain I would simply call Update, considering that GetChanges
makes a copy of the data and Update only looks at the changed rows anyway...
Or if order of updates was important (Add, Delete, Update) I would use the
method outlined in Sceppa's book.

Cross AppDomains I would recommend the GetChanges method outlined in
Sceppa's book

David Sceppa's book "Microsoft ADO.NET - Core Reference" from MS Press has a
really good write-up on getting database changes to work across AppDomains
w/DataSet.GetChanges & DataSet.Merge...

Hope this helps
Jay
 
Thanks everyone, for the valuable suggestions/comments. And HD, sorry to
jump on your case :-) I thought you were just giving me a hard time, and I
needed answers more than I needed a hard time <g>

-Eric
 
Back
Top