Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

PRB: Space in ConnectString Does Not Allow Pessimistic Locking


View products that this article applies to.

This article was previously published under Q246360

↑ Back to the top


Symptoms

Placing a space in the ConnectString after the keyword Provider will not allow the use of pessimistic locking (adLockPessimistic).

↑ Back to the top


Resolution

Remove the space from the ConnectString.

↑ Back to the top


Status

This behavior is by design.

↑ Back to the top


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

  1. Start a new Visual Basic Standard EXE project. Form1 is added by default.
  2. From the Project menu, click References, and select the Microsoft ActiveX Data Objects.
  3. 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
    					
  4. Run the Project.

Result: You receive a BatchOptimistic (4) instead of a Pessimistic lock (2).

↑ Back to the top


Keywords: KB246360, kbprb, kbfix

↑ Back to the top

Article Info
Article ID : 246360
Revision : 4
Created on : 12/3/2003
Published on : 12/3/2003
Exists online : False
Views : 414