HighTechTalks DotNet Forums  

Concurreny with Datasets

Dotnet Framework (ADO.net) microsoft.public.dotnet.framework.adonet


Discuss Concurreny with Datasets in the Dotnet Framework (ADO.net) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Ant
 
Posts: n/a

Default Concurreny with Datasets - 09-03-2006 , 08:45 AM






Hi,

Is there a way to check if a records in the underlying database have been
updated by another client?

ds.HasChanges() method only tells you that the DataSet has changed from the
initial underlying data, but how do you know if another client has changed
the underlying data that you are just about to send changes to from your own
DataSet to?

Do you need to create a temporary DataSet to at the time of updating in
order to determine if any new changes exist against the modified original
rows?

Is this how its done?

thanks for any ideas in advance
Ant

Reply With Quote
  #2  
Old   
Cor Ligthert [MVP]
 
Posts: n/a

Default Re: Concurreny with Datasets - 09-03-2006 , 09:41 AM






Ant,

If you are using the commandbuilder, the standard by the wizards created or
yourself created sql string, than there is a select in that to check the
original that you have retrieved from the database to the current situation.

For that are now more methods in 2005 however assume the old method. In that
is checked every column if that what was original read by the dataadapter is
still the same. Is that not, than an error will be throwed and can you do
what you want to solve that. One of the probably most used options is
probably doing a rollback using the connection object..

I hope that this gives an idea?

Cor

"Ant" <Ant (AT) discussions (DOT) microsoft.com> schreef in bericht
news:2CF2A466-F513-47BD-A6D3-6E83965A683A (AT) microsoft (DOT) com...
Quote:
Hi,

Is there a way to check if a records in the underlying database have been
updated by another client?

ds.HasChanges() method only tells you that the DataSet has changed from
the
initial underlying data, but how do you know if another client has changed
the underlying data that you are just about to send changes to from your
own
DataSet to?

Do you need to create a temporary DataSet to at the time of updating in
order to determine if any new changes exist against the modified original
rows?

Is this how its done?

thanks for any ideas in advance
Ant



Reply With Quote
  #3  
Old   
Miha Markic [MVP C#]
 
Posts: n/a

Default Re: Concurreny with Datasets - 09-03-2006 , 04:22 PM



Hi Ant,

Why would you need to know?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Ant" <Ant (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi,

Is there a way to check if a records in the underlying database have been
updated by another client?

ds.HasChanges() method only tells you that the DataSet has changed from
the
initial underlying data, but how do you know if another client has changed
the underlying data that you are just about to send changes to from your
own
DataSet to?

Do you need to create a temporary DataSet to at the time of updating in
order to determine if any new changes exist against the modified original
rows?

Is this how its done?

thanks for any ideas in advance
Ant



Reply With Quote
  #4  
Old   
Ant
 
Posts: n/a

Default Re: Concurreny with Datasets - 09-03-2006 , 07:43 PM



Hi, Cor,

Thanks for the advice. I think that's probably the best way. I didn't
realize that optimistic concurrency was a default. Now I see that it throws
an error on finding the underlying data changed, I can work with that. Thanks
again.


Hello Miha,

Why would I want to know? well, I have a server with a few clients each
holding a Dataset derived from the data on the server. Datasets are
disconnected. If one user updates a row back to the server on one client,
then another user updates the same row from a dataset on another client, the
two different updates may cause data integrity problems. Which update would
be correct? (what if only col 1 was updated in update 1 but only col 2 was
updated in update two; I would lose the col 1 update).

So I need to control this.
Hope this helps

Thanks for your help
Ant

"Miha Markic [MVP C#]" wrote:

Quote:
Hi Ant,

Why would you need to know?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Ant" <Ant (AT) discussions (DOT) microsoft.com> wrote in message
news:2CF2A466-F513-47BD-A6D3-6E83965A683A (AT) microsoft (DOT) com...
Hi,

Is there a way to check if a records in the underlying database have been
updated by another client?

ds.HasChanges() method only tells you that the DataSet has changed from
the
initial underlying data, but how do you know if another client has changed
the underlying data that you are just about to send changes to from your
own
DataSet to?

Do you need to create a temporary DataSet to at the time of updating in
order to determine if any new changes exist against the modified original
rows?

Is this how its done?

thanks for any ideas in advance
Ant




Reply With Quote
  #5  
Old   
Miha Markic [MVP C#]
 
Posts: n/a

Default Re: Concurreny with Datasets - 09-04-2006 , 03:50 AM



Hi Ant,

I think that you are not doing it right.
So, you check whether the data wasn't changed on database and then you do an
update if data wasn't changed, correct?
If so, then it is wrong and a performance hit. What if somebody changes data
between your check and your update?
See, you can't know that data wasn't changed before doing an update (unless
you heavily lock your database) and you don't need to.
Just try to do an update wrapped in a transaction and using concurrency
checking. If the update succeeds then it is ok, if it doesn't succeed then
you will know that data was changed and decide what do to.

HTH
--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Ant" <Ant (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi, Cor,

Thanks for the advice. I think that's probably the best way. I didn't
realize that optimistic concurrency was a default. Now I see that it
throws
an error on finding the underlying data changed, I can work with that.
Thanks
again.


Hello Miha,

Why would I want to know? well, I have a server with a few clients each
holding a Dataset derived from the data on the server. Datasets are
disconnected. If one user updates a row back to the server on one client,
then another user updates the same row from a dataset on another client,
the
two different updates may cause data integrity problems. Which update
would
be correct? (what if only col 1 was updated in update 1 but only col 2 was
updated in update two; I would lose the col 1 update).

So I need to control this.
Hope this helps

Thanks for your help
Ant

"Miha Markic [MVP C#]" wrote:

Hi Ant,

Why would you need to know?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Ant" <Ant (AT) discussions (DOT) microsoft.com> wrote in message
news:2CF2A466-F513-47BD-A6D3-6E83965A683A (AT) microsoft (DOT) com...
Hi,

Is there a way to check if a records in the underlying database have
been
updated by another client?

ds.HasChanges() method only tells you that the DataSet has changed from
the
initial underlying data, but how do you know if another client has
changed
the underlying data that you are just about to send changes to from
your
own
DataSet to?

Do you need to create a temporary DataSet to at the time of updating in
order to determine if any new changes exist against the modified
original
rows?

Is this how its done?

thanks for any ideas in advance
Ant






Reply With Quote
  #6  
Old   
Ant
 
Posts: n/a

Default Re: Concurreny with Datasets - 09-04-2006 , 05:35 AM



Hi Miha,

Thanks for the tip. Using a transaction would certainly remove any further
risks that might occur during the update.
Cheers
Ant


"Miha Markic [MVP C#]" wrote:

Quote:
Hi Ant,

I think that you are not doing it right.
So, you check whether the data wasn't changed on database and then you do an
update if data wasn't changed, correct?
If so, then it is wrong and a performance hit. What if somebody changes data
between your check and your update?
See, you can't know that data wasn't changed before doing an update (unless
you heavily lock your database) and you don't need to.
Just try to do an update wrapped in a transaction and using concurrency
checking. If the update succeeds then it is ok, if it doesn't succeed then
you will know that data was changed and decide what do to.

HTH
--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Ant" <Ant (AT) discussions (DOT) microsoft.com> wrote in message
news:0B99D728-DCB5-4613-AD6A-6CC67D443998 (AT) microsoft (DOT) com...
Hi, Cor,

Thanks for the advice. I think that's probably the best way. I didn't
realize that optimistic concurrency was a default. Now I see that it
throws
an error on finding the underlying data changed, I can work with that.
Thanks
again.


Hello Miha,

Why would I want to know? well, I have a server with a few clients each
holding a Dataset derived from the data on the server. Datasets are
disconnected. If one user updates a row back to the server on one client,
then another user updates the same row from a dataset on another client,
the
two different updates may cause data integrity problems. Which update
would
be correct? (what if only col 1 was updated in update 1 but only col 2 was
updated in update two; I would lose the col 1 update).

So I need to control this.
Hope this helps

Thanks for your help
Ant

"Miha Markic [MVP C#]" wrote:

Hi Ant,

Why would you need to know?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Ant" <Ant (AT) discussions (DOT) microsoft.com> wrote in message
news:2CF2A466-F513-47BD-A6D3-6E83965A683A (AT) microsoft (DOT) com...
Hi,

Is there a way to check if a records in the underlying database have
been
updated by another client?

ds.HasChanges() method only tells you that the DataSet has changed from
the
initial underlying data, but how do you know if another client has
changed
the underlying data that you are just about to send changes to from
your
own
DataSet to?

Do you need to create a temporary DataSet to at the time of updating in
order to determine if any new changes exist against the modified
original
rows?

Is this how its done?

thanks for any ideas in advance
Ant







Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.