Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiuser operation of Acces Jet Engine via VB 2

Status
Not open for further replies.

adamr1001

MIS
Jul 25, 2001
166
CA
I am in the process of creating a VB application that will use the Jet Engine to connect to many MDB files (access). My question is: how do I ensure that when one workstation connects to a specific MDB file, another workstation that tries to connect to the same file will be locked? I read somewhere that there is VB code that i can use. Much appreciated to anyone who can help me out. Thanks in advance, and more to come upon a reply, Adam.
 
You can determine this with the following code:

adoConn.Mode = adModeShareExclusive

where adoConn is your ADO connection object.

there are also other modes you can use (click on Mode and hit F1 to pull up the details).

Hope this helps! Best Regards and many Thanks!
Michael G. Bronner X-)

"Who cares how time advances? I am drinking [beer] today." Edgar Allan Poe
 
Here are the different levels of database locking available, from most secure to least secure:


Dim db as Database
Dim rs as Recordset

'exclusive mode, no other user can change any record in the db when you do this:
Set db = OpenDatabase("..\..\MyDb.mdb", True)

'Table-level locking:
Set rs = OpenRecordset("tblMyTable", dbOpenTable, dbDenyWrite + dbDenyRead)

'Optimistic locking:
Set rs = db.OpenRecordset("tblMyTable", dbOpenDynaset, False, dbOptimistic)
rs.Edit 'this starts the optimistic lock
'user does stuff here
rs.Update 'this should cause error if another app has record locked

'Pessimistic locking:
(same as Optimistic locking, only error will happen on the rs.Edit line, not rs.Update)

Hope this helps!

-Mike








Difference between a madman and a genius:
A madman uses his genius destructively,
A genius uses his madness constructively.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top