70 likes | 224 Views
Database Access: Multi-User Databases. Multi-User Issues Locking Schemes Database Locking Recordset Locking Record Locking. Multi-User Issues. Database access Database security Data currency Locking
E N D
Database Access: Multi-User Databases • Multi-User Issues • Locking Schemes • Database Locking • Recordset Locking • Record Locking University of South Alabama School of CIS
Multi-User Issues • Database access • Database security • Data currency • Locking • a process whereby the current user of information in a database controls or limits access to some or all of that information by other users while the current user has access. • locking is used to prevent simultaneous update attempts • Application performance University of South Alabama School of CIS
Locking Schemes • Database Locking • Recordset Locking • Record Locking University of South Alabama School of CIS
Database Locking • Lock an entire database when opening • Simplest, yet most restrictive method • Example: Dim ConnDB As new ADODB.Connection ConnDB.Open “Provider=Microsoft.Jet.OLEDB.3.51;” & _ “Persist Security Info=False;” & _ “Data Source=C:\Company.mdb;” & _ “Mode=Read|Write|Share Deny Read|Share Deny Write” University of South Alabama School of CIS
Recordset Locking • Deny read access • prevents users from reading the records • Deny write access • prevents users from writing to recordset • Locking remains in effect as long as the recordset is opened by your (the locking) program • ADO supports deny write access recSet.Open “Employees”, connDB, _ adOpenKeyset, adLockReadOnly University of South Alabama School of CIS
Record Locking • Done automatically by VB • Record locking is an alternative to database or recordset locking • Other users can read, but not change locked record University of South Alabama School of CIS
Optimistic and Pessimistic Record Locking • Pessimistic Locking • locks current record when editing buffer • releases record when .Update is finished writing record • Optimistic Locking • locks record when .Update method is invoked • releases record when .Update is finished • Must set the LockType property recSet.Open “Employees”, connDB, _ adOpenKeyset, adLockOptimistic ‘* optimistic locking recSet.Open “Employees”, connDB, _ adOpenKeyset, adLockPessimistic ‘* pessimistic locking University of South Alabama School of CIS