Locking Recordsets in Microsoft Access 2000 Hawaii

Don't get locked out! Have you ever had trouble knowing what is and isn't locked when working with a Microsoft Access program? VBA offers several alternative locking strategies for the developer, ranging from locking the entire database to locking one record at a time. In addition, VBA lets you control how long data will be locked. This article shows you how.

Local Companies

Advanced Data Services
(808) 325-5251
73-4354 Mamalahoa Hwy Ste 207
Kailua Kona, HI
Kona Impact LLC
(808) 329-6077
75-5759 Kuakini Hwy Ste 103a
Kailua Kona, HI
The Computer People
(808) 214-4572
1215 S Kihei Rd # 0-307
Kihei, HI
Advanced Management Systems
(808) 935-5500
PO Box 11434
Hilo, HI
Alfalfas.net
(808) 968-7399
18 1314 Ol Volcano Rd
Hilo, HI
808 Computers
(808) 331-1808
73-4531 Iki Pl
Kailua Kona, HI
Falcon Computers
(808) 334-1988
75-5629 Kuakini Hwy Ste E2
Kailua Kona, HI
Tech Projects LLC
(808) 891-2300
480 Kenolio Rd
Kihei, HI
Technology Solutions Hawaii
(808) 345-3256
PO Box 7520
Hilo, HI
Akamai Kids
(808) 895-4089
54 Kapaa St # 424
Hilo, HI

provided by: 
Originally published at Internet.com


Recordset Locking



Recordset locking locks pages of data found in a recordset. By using recordset locking, you can control when and for how long the data is locked. This is different from locking data through bound forms, which gives you little control over the specifics of the locking process.

When you're traversing through a recordset, editing and updating data, locking occurs regardless of whether you intervene, so you must understand when the locking occurs and whether you need to step in to intercept the default behavior. If you do nothing, a record, or possibly an entire page of records, will be locked each time you begin editing data from your VBA code. This record page is 4096 bytes (4K) and surrounds the record being edited. If an OLE object is found in the record being edited, it isn't locked with the record because it occupies its own space.

Pessimistic Locking



VBA lets you determine when and for how long a page is locked. The default behavior is called pessimistic locking, which means that the record or page is locked when the first field is updated. Listing 1 illustrates this process.

Listing 1 - Utilizing Pessimistic Locking Sub PessimisticLock(strAuthorID As String) Dim cnn As ADODB.Connection Dim rst As ADODB.Recordset Dim strCriteria As String Set cnn = New ADODB.Connection cnn.ConnectionString = " Provider=sqloledb;" & _ "Data Source=(local);Initial Catalog=pubs;uid=sa;pwd=" cnn.Open Set rst = New ADODB.Recordset rst.ActiveConnection = cnn rst.CursorType = adOpenKeyset rst.LockType = adLockPessimistic 'Invoke Pessimistic Locking rst.CursorLocation = adUseServer rst.Open "Select * from Authors Where Au_ID ='" _ & strAuthorID & "'", _ Options:=adCmdText rst!City = "Thousand Oaks" 'Lock occurs here rst.Update 'Lock Released Here End Sub NOTE Not all database providers support all lock types. To determine the functionality available for a particular Recordset object, use the Supports method with adUpdate and adUpdateBatch. Furthermore, the adLockPessimistic setting is not supported when the CursorLocation property is set to adUseClient. Whether the provider does not support the locking type, or the cursor location does not support the locking type, no error results. Instead, the closest available locking type is used...

Read article at Internet.com site

Featured Local Company

808 Computers

(808) 331-1808
73-4531 Iki Pl
Kailua Kona, HI
http://www.808computers.com

Related Articles
- Seeing through the hype: Web Services Hawaii
"We are in the early stages of a yet another dramatic shift in computing paradigms." This statement was made by Marge Breya, Chief Marketing Officer of iPlanet in reference to Web Services. Is this just hype?
- Using DMAIC Methodology to Enhance Information Portals Hawaii
- Encrypting an Access Database Hawaii
- Zen and the Art of Breaking Security - Part II Hawaii
- URL, URL, Little Do We Know Thee Hawaii
- Email Filtering: The Real Deal Hawaii
- Understanding the Microsoft Access Runtime Engine Hawaii
Related Articles
- Seeing through the hype: Web Services Hawaii
"We are in the early stages of a yet another dramatic shift in computing paradigms." This statement was made by Marge Breya, Chief Marketing Officer of iPlanet in reference to Web Services. Is this just hype?
- Using DMAIC Methodology to Enhance Information Portals Hawaii
- Encrypting an Access Database Hawaii
- Zen and the Art of Breaking Security - Part II Hawaii
- URL, URL, Little Do We Know Thee Hawaii
- Email Filtering: The Real Deal Hawaii
- Understanding the Microsoft Access Runtime Engine Hawaii

Topics: 
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML