You can work around the problem by using one of the
following methods:
Use a Server-Side Cursor
You can use a server-side cursor instead of a client-side cursor.
To do this, open the client-side cursor by setting the
CursorLocation property of the recordset to
adUseServer.
For example, you may use code that is similar to the following
code.
Note The sample code in this article uses Microsoft ActiveX Data
Objects. For this code to run correctly, you must reference the Microsoft
ActiveX Data Objects 2.x Library (where 2.x is 2.1 or later). To do so, click
References on the
Tools menu in the Visual
Basic Editor, and make sure that the
Microsoft ActiveX Data Objects 2.x
Library check box is selected.
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strPath As String
'Update the following path to point to the sample
'Northwind.mdb database on your computer.
strPath = "C:\Program Files\Microsoft Office\Office11\Samples\Northwind.mdb"
'Create a new ADO Connection to Northwind
'by using Access and the Jet OLE DB
'provider.
Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.Access.OLEDB.10.0"
.Properties("Data Provider").Value = "Microsoft.Jet.OLEDB.4.0"
.Properties("Data Source").Value = strPath
.Open
End With
'Create a new ADO Recordset by using a server-side
'keyset cursor and optimistic locking.
Set rs = New ADODB.Recordset
With rs
.ActiveConnection = cn
.Source = "SELECT * FROM Categories"
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.CursorLocation = adUseServer
.Open
End With
Use Either or Both the Shape Provider or the Jet Provider
Do not use the Access 10.0 provider. If you have to access the
data without shaping services, you can use only the Jet provider to open the
ADO connection.
For example, you may use code that is similar to the
following code to open an ADO connection with the Jet OLE DB provider:
Dim cn As ADODB.Connection
Dim strPath As String
'Update the following path to point to the sample
'Northwind.mdb database on your computer.
strPath = "C:\Program Files\Microsoft Office\Office11\Samples\Northwind.mdb"
'Create a new ADO Connection to Northwind
'by using Access and the Jet OLE DB
'provider.
Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Data Source").Value = strPath
.Open
End With
If you must have the shaping services support for hierarchical
recordsets, you can use the Shape (MSDataShape) provider together with the Jet
provider to open your ADO connection.
For example, you may use code
that is similar to the following code:
Dim cn As ADODB.Connection
Dim strPath As String
'Update the following path to point to the sample
'Northwind.mdb database on your computer.
strPath = "C:\Program Files\Microsoft Office\Office11\Samples\Northwind.mdb"
'Create a new ADO Connection to Northwind
'by using Access and the Jet OLE DB
'provider.
Set cn = New ADODB.Connection
With cn
.Provider = "MSDataShape"
.Properties("Data Provider").Value = "Microsoft.Jet.OLEDB.4.0"
.Properties("Data Source").Value = strPath
.Open
End With