dotnet0824
asked on
Typed Dataset Concurrency
hi,
i have a typed dataset and bulk update being implemented... if there is a dbconcurreny exception would it be caught at the try catch statements or should i have to have catch dbconcurreny as exception added.
I dont have timestamp column in my tables... Should i do something for implementing update concurrency or would the error be populated automatically
Try
update(ds)
catch ex as exception
end try
i have a typed dataset and bulk update being implemented... if there is a dbconcurreny exception would it be caught at the try catch statements or should i have to have catch dbconcurreny as exception added.
I dont have timestamp column in my tables... Should i do something for implementing update concurrency or would the error be populated automatically
Try
update(ds)
catch ex as exception
end try
And this goes for stored procedures
http://msdn2.microsoft.com/en-us/library/7ztw9ch6(VS.71).aspx
But what really are important is a basic understanding of what concurrency is and how to deal with it!
Introduction to Data Concurrency in ADO.NET
http://msdn2.microsoft.com/en-us/library/cs6hb8k4(VS.71).aspx
If further assistance is required then just drop a post
vbturbo
http://msdn2.microsoft.com/en-us/library/7ztw9ch6(VS.71).aspx
But what really are important is a basic understanding of what concurrency is and how to deal with it!
Introduction to Data Concurrency in ADO.NET
http://msdn2.microsoft.com/en-us/library/cs6hb8k4(VS.71).aspx
If further assistance is required then just drop a post
vbturbo
ASKER
thanks.. i know how to handle concurrency . My question is lets say I dont handle concurreny issues what would happen if two users update a dataset at the same time. Would it throw an error ..can that part be explained
Well there are 2 ways to handle this
How to handle optimistic concurrency violations
http://articles.techrepublic.com.com/5100-22-1050110.html
Pessimistic locking solves ADO.NET concurrency problems
http://articles.techrepublic.com.com/5100-22_11-1049842.html
And you handle this with a designer/wizzard
http://articles.techrepublic.com.com/5100-22-1050108.html
ASKER
Hi VbTurbo. Thanks a lot for all the posts. I have also increased the points.
I have seen this. Nothing was handled for concurrency instead it is just caught in try catch block.
Would this work too ........
try
{
SqlDataAdapter1.Update(myD ataset);
}
catch (DBConcurrencyException ex)
{
string customErrorMessage;
customErrorMessage = "Concurrency violation\n";
customErrorMessage += ex.Row[0].ToString();
// Replace the above code with appropriate business logic
// to resolve the concurrency violation.
}
http://msdn2.microsoft.com/en-us/library/y8fyz6xy(VS.71).aspx
I have seen this. Nothing was handled for concurrency instead it is just caught in try catch block.
Would this work too ........
try
{
SqlDataAdapter1.Update(myD
}
catch (DBConcurrencyException ex)
{
string customErrorMessage;
customErrorMessage = "Concurrency violation\n";
customErrorMessage += ex.Row[0].ToString();
// Replace the above code with appropriate business logic
// to resolve the concurrency violation.
}
http://msdn2.microsoft.com/en-us/library/y8fyz6xy(VS.71).aspx
ASKER
if it works why do we need to implement other methodoligies posted earlier. Thats what I couldnt understand
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
this would perhaps also interrest you
https://www.experts-exchange.com/questions/22370631/Autonumber-isn't-returned-from-new-record-in-empty-dataset.html
https://www.experts-exchange.com/questions/22370631/Autonumber-isn't-returned-from-new-record-in-empty-dataset.html
ASKER
Thanks a lot
Just one more tip
Lets assume a scenario where a big travel agency with 50 branches around the country sells flight tickets.
you arrive in 1 branch and i in another one.
now without knowing we are now trying to buy the same last seat on the same flight
for a well deserved vacation -:)
in this particular scenario a transaction solution would fit our way to handle this issue
lets say that your agent is a split second faster than mine.
your agent's system now put a lock on this particular row (eighter pessimistic or optimistic)
you would be the first in a que buffer to that gets handle'd , i the second , maybee another as the third one
now all the members in the que buffer now gets assigned to the transactions in the order the come in the line!
if you accept the ticket , the rest of the members in the que gets disappointed ( including me)
since the system signals (the row status as occupied) one by one (each time a transaction gets excecuted)
here you would use a pessimistic choise to handle concurrency
sorry for the lack of conceptual explanation but hope you got the picture.
vbturbo
Lets assume a scenario where a big travel agency with 50 branches around the country sells flight tickets.
you arrive in 1 branch and i in another one.
now without knowing we are now trying to buy the same last seat on the same flight
for a well deserved vacation -:)
in this particular scenario a transaction solution would fit our way to handle this issue
lets say that your agent is a split second faster than mine.
your agent's system now put a lock on this particular row (eighter pessimistic or optimistic)
you would be the first in a que buffer to that gets handle'd , i the second , maybee another as the third one
now all the members in the que buffer now gets assigned to the transactions in the order the come in the line!
if you accept the ticket , the rest of the members in the que gets disappointed ( including me)
since the system signals (the row status as occupied) one by one (each time a transaction gets excecuted)
here you would use a pessimistic choise to handle concurrency
sorry for the lack of conceptual explanation but hope you got the picture.
vbturbo
Well this is how i would handle concurrency
http://msdn2.microsoft.com/en-us/library/ks9f57t0(vs.71).aspx
This goes for both ms-sql and ms-access
vbturbo