DAO 3.6 and Record level locking

D

dpnews

My VB6 app used DAO 3.5 in page locking mode. WHen a locking error accured
you could trap error 3260 which told you the workstation name that was
locking the page.

I have upgraded my app to use DAO 3.6 and us the ADO method to open the
database in record locking mode before openning it with DAO.

Global db_comp As DAO.DataBase
Global wsDAO As DAO.Workspace

Dim cnn As ADODB.Connection

'ADO has the ability to open row-level locking; DAO does not.
'The following code is used to implement row-level locking in DAO.
'If the database is opened first in row-level locking in ADO,
'subsequent attempts to open the database in ADO and DAO will use
the same mode.

Set cnn = New ADODB.Connection
cnn.Provider = "Microsoft.JET.OLEDB.4.0"
cnn.Properties("Data Source") = Company
cnn.Properties("Jet OLEDB:Database Locking Mode") = 1
cnn.CursorLocation = adUseServer
cnn.Open

Set wsDAO = DBEngine.CreateWorkspace("WorkSpace", "Admin", "",
dbUseJet)

Err.Clear
Set db_comp = wsDAO.OpenDatabase(Company, SingleUser, False)


When a locking error occurs now I get error 3218. This does not specify who
is locking the record.

Does anyone know how to acheive this as it is extreemly useful

Cheers
Dave
 
D

Douglas J. Steele

You're making two different connections to the database, and Access doesn't
know that it's the same user making both connections. In other words, you're
probably the one locking the record!

If you want to use that ADO locking option, you must do the rest of your
querying using that same connection.
 
D

dpnews

No its not me locking the record.
The ADO connection is used to invoke record level locking when the DAO
connection to teh database is opened.
The ADO connection is then closed.

The DAO connection remains open.

I know its not me locking the record as if the other user exits from teh
record then I can get access OK.

Using the old method without the ADO code to use record level locking the
system uses page level locking and you get a different error when a record is
locked. This message gives you the workstation name.

The new method does not give you the workstation name
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top