Question : Pessimistic Locking with Access ADO and SQL Server

Hello All

I am trying to get a definitive answer as to whether it is possible to acheive a pessimistic lock with ADO.
I am using an MS Access 2003 .mdb front end connected to SQL Server 2005.

I have a routine that creates a recordset that I need to be locked from the point of opening (no .edit command in ADO) to the point the update command is issued.

I have opened a connection using the sqloledb provider and set it's cursor locaion to adUseServer (I believe this is the default anyway)

I have then instantiated a recordset and set its 'Lock Type' to pessimistic, 'Cursor Type' to keyset and 'Cursor Location' to server side.

I have tried all manner of combinations of these parameters and I simply cannot achieve a lock.  I can open a new instance of the front end and happily update the record while to other instance supposedly has it locked.

I know that using an sp is probably the way to go, but I don't know enough T-SQL to be confident enough to produce one - and in any case, the options are there, so they should work surely!

I've been at this for three solid days now and it's driving me nuts!

Any help greatly appreciated!

Andy

Answer : Pessimistic Locking with Access ADO and SQL Server

The difference between the two lock types is not quite what you think, rather it's the time in which the row / page is locked.

Pessimistic lock will occur when the record starts to be edited, while optimistic locks when the record is updated. The difference between these two (in terms of time) maybe very short.

From the sounds of things, you're trying to achieve something different?

Dave
Random Solutions  
 
programming4us programming4us