() FIX: Blank Space in ConnectString Won't Allow Pessimistic Locking
ID: Q246360
|
The information in this article applies to:
-
Microsoft Visual Basic Enterprise Edition for Windows, version 6.0
-
ActiveX Data Objects (ADO), versions 2.0, 2.1, 2.1 SP2
SYMPTOMS
Placing a space in the ConnectString after the keyword Provider will not allow the use of pessimistic locking (adLockPessimistic).
RESOLUTION
Remove the space from the ConnectString.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article.
This bug was corrected in MDAC 2.5.
MORE INFORMATION
This only happens using the SQLOLEDB, Jet 3.51 and Jet 4.0 OLEDB Providers with Server-Side cursors and Pessimistic Locking.
Steps to Reproduce Behavior
- Start a new Visual Basic Standard EXE project. Form1 is added by default.
- From the Project menu, click References, and select the Microsoft ActiveX Data Objects.
- Place the following code in the Code Window of Form1.
Private Sub Form_Load()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
set cn = New ADODB.Connection
set rs = New ADODB.Recordset
cn.Open "Provider =Microsoft.jet.oledb.3.51;Data Source=c:\Program Files\Microsoft Visual Studio\VB98\nwind.mdb" 'Causes Problem
'cn.open "Provider=Microsoft.jet.oledb.3.51;Data Source=c:\Program Files\Microsoft Visual Studio\VB98\nwind.mdb" 'Does not cause the problem
With rs
.CursorLocation = adUseServer
.CursorType = adOpenKeyset
.LockType = adLockPessimistic
.Open "Select * from Customers", cn
End With
Debug.Print rs.CursorLocation 'Should be 2
Debug.Print rs.CursorType 'Should be 1
Debug.Print rs.LockType 'Should be 2 but you get 4
End Sub
- Run the Project.
Result: You receive a BatchOptimistic (4) instead of a Pessimistic lock (2).
© Microsoft Corporation November 16, 1999, All Rights Reserved.
Contributions by Terrell D. Andrews, Microsoft Corporation
Additional query words:
Keywords : kbMDAC kbOLEDB kbVBp kbVBp600 kbWinOS95 kbWinOS98 kbGrpVBDB kbGrpMDAC kbDSupport kbADO210sp2 kbMDAC210bug kbMDAC250fix kbADO250
Version : WINDOWS:2.0,2.1,2.1 SP2,6.0
Platform : WINDOWS
Issue type : kbbug