Showing posts with label lock. Show all posts
Showing posts with label lock. Show all posts

Monday, March 19, 2012

How can I lock and release table

How can I lock and release table
I need to assign user table to acess table only one time and after access
the table will lock
and how to release the table after lock
Thank you for all thinking shareIt's hard to suggest something without more info. Take a look at lock hints
in the BOL
"Pure_haven" <u32445@.uwe> wrote in message news:6f1b82bbe0020@.uwe...
> How can I lock and release table
> I need to assign user table to acess table only one time and after
> access
> the table will lock
> and how to release the table after lock
> Thank you for all thinking share
>

How can i lock a record

hi all iam working on a ticketing application i want to avoid two users to book the same ticket the requirement is as follows

1. the system should show all the available tickets which is not yet booked

2.when two users book the ticket at the same time time it should not allow the two persons to update at the same tme

the main aim is to avoid data concurency

how can i get this done

Use a flag or the best is to use time-stamps?

|||

Hi,

From your description, it seems that your problem is related to SQL concurrency issue.
Suppose each ticket is saved in your data table. For your first requirement, it can be achieved by using a flag which indicates if the ticket has been booked or not.
For your second requirement, since ADO.NET uses Optimistic Concurrency. Then locks are set and held only while the database is being accessed. The locks prevent other users from attempting to update records at the same instant. The data is always available except for the exact moment that an update is taking place.

In Optimistic Concurrency, there are two general ways to determine if changes have occurred: the version approach (true version numbers or date-time stamps) and the saving all values approach.

i.e. For Version Number approach, the record to be updated must have a column that contains a date-time stamp or version number. The date-time stamp or a version number is saved on the client when the record is read. This value is then made part of the update.

For more information, seehttp://msdn2.microsoft.com/en-us/library/cs6hb8k4(VS.71).aspx

Thanks!