Concurrency issue: Dataset Has no changes but database Has

rekiller

New member
Joined
May 27, 2008
Messages
3
Programming Experience
5-10
My problem is simple.
I have a dataset in my app, but i dont make any changes.

Someone else, with another app, or database admin, change some data.
When i save my dataset, it dont save anything cause it no has changes, but it must to save.

Supose, my Age is 20. I open my app, and i see that my age is 20.
Then, other person with other open app, or the database admin changed my age to 18. After that, i still see that my age is 20 cause I dont have make changes and my datase has not been refreshed. Suposse i dont make changes, but i want to save data cause i want my Age =20, it doesnt fire Update Event for the DataAdapter, because it no has changes. So, i think that i updated my age, but when i reopen my app or refresh dataset i see that my age now is 18.

I dont want this to happen, because my decission was the last, and the correct age has to be 20.

I am using tableadapater.update(dataset.DatasetTable) with concurrency activated.

How to deal with this?? I though that concurrency has to fire, but it does not.
 
If you don't make a change in your local copy of data then Update (ie. "Save") does nothing, concurrency control only applies at the time of load or during an actual update of data. The only way for you to see if others have made changes since last time you loaded data is to load again. That is how the disconnected ADO.Net architecture works. To save time loading you can use different variations of datetime/version stamps which you check first to see if a new load is necessary. Read more about this in help documentation article Introduction to Data Concurrency in ADO.NET
 
Thanks, I had use timestamps, and manage this type of concurrency on ado.net 1.x

I only asked this cause I'm learning ado.net 2.0, and I was happy about this concurrency control, and i though It can do what i wanted, but i see that it can't.

So, this type of control should improve more to complete my expectations.
 
OK, so youre saying that you want to be able to save a row to the database regardless of whether it has changed...

This means your concurrency control is non existent, you just adopt a "last horse past the post wins" strategy.. That;s fine

TabelAdapter WONT update (send to the db) a row that is RowState Unchanged.. so just call SetModified on the row you want to send to the DB BEFORE you send it

http://msdn.microsoft.com/en-us/library/system.data.datarow.setmodified.aspx

because its modified (even though no data changed), ADO.NET will sent it to the db and age 18 will just get overwritten with 20.

Seems a bit dumb to me, but hey.. it's your app!
 
Back
Top