You cannot update ADO recordset using Access OLE DB provider in Access 2002 (287455)
The information in this article applies to:
This article was previously published under Q287455 Advanced: Requires expert coding, interoperability, and multiuser skills.
This article applies only to a Microsoft Access database (.mdb).
SYMPTOMS
When you try to edit a field in an ADO recordset by using the Microsoft Access and the Microsoft Jet OLE DB providers, you receive the following error:
Run-time error '3251':
Current Recordset does not support updating. This may be a limitation of the provider or of the selected locktype.
CAUSE
The CursorLocation property of the recordset is set to adUseClient to open a client-side cursor.
RESOLUTION
There are two possible methods you can use to work around this problem:
- You can use a server-side cursor.
- You can use either or both the Shape or the Jet OLE DB providers to open the connection.
Use a Server-Side Cursor
You can use a server-side cursor instead of a client-side cursor. You can open a client-side cursor by setting the CursorLocation property of the recordset to adUseServer. For an example of this, see the following code segment:
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strPath As String
'Update the path below to point to the sample
'Northwind.mdb database on your computer.
strPath = "C:\Program Files\Microsoft " & _
"Office\Office10\Samples\Northwind.mdb"
'Create a new ADO Connection to Northwind
'using the Microsoft Access and Jet OLE DB
'providers.
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 or the Jet Providers
To work around this problem, do not use the Microsoft Access 10.0 provider. If you have to access the data without shaping services, then you can use only the Jet provider to open the ADO connection. For example, you may use code similar to the following to open an ADO connection with the Jet OLE DB provider.
Dim cn As ADODB.Connection
Dim strPath As String
'Update the path below to point to the sample
'Northwind.mdb database on your computer.
strPath = "C:\Program Files\Microsoft " & _
"Office\Office10\Samples\Northwind.mdb"
'Create a new ADO Connection to Northwind
'using the Microsoft Access and Jet OLE DB
'providers.
Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Data Source").Value = strPath
.Open
End With
If you need shaping support for hierarchical recordsets, use the Shape (MSDataShape) provider together with the Jet provider to open your ADO connection. For an example of this, see the following code segment:
Dim cn As ADODB.Connection
Dim strPath As String
'Update the path below to point to the sample
'Northwind.mdb database on your computer.
strPath = "C:\Program Files\Microsoft " & _
"Office\Office10\Samples\Northwind.mdb"
'Create a new ADO Connection to Northwind
'using the Microsoft Access and Jet OLE DB
'providers.
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
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Minor | Last Reviewed: | 8/12/2004 |
---|
Keywords: | kbprb kbnofix KB287455 |
---|
|