Looks like you need to use a different cursor type. This worked for me when
I changed the cursor type from adOpenStatic to adOpenKeyset ...
Public Sub TestGetId()
Const strcConnect As String = "Provider=SQLOLEDB.1;" & _
"Integrated Security=SSPI;" & _
"Persist Security Info=False;" & _
"Initial Catalog=Northwind;" & _
"Data Source=(local)"
Dim cn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim fld As ADODB.Field
Set cn = New ADODB.Connection
cn.ConnectionString = strcConnect
cn.Open
Set rst = New ADODB.Recordset
' rst.Open "SELECT * FROM Categories", cn, adOpenStatic, _
' adLockPessimistic
rst.Open "SELECT * FROM Categories", cn, adOpenKeyset, _
adLockPessimistic
rst.AddNew
rst.Fields("CategoryName") = "Test"
rst.Fields("Description") = "A Test Category"
rst.Update
Debug.Print rst.Fields("CategoryID"), _
rst.Fields("CategoryName"), rst.Fields("Description")
rst.Close
cn.Close
End Sub
--
Brendan Reynolds
Access MVP
"GeorgeAtkins" <GeorgeAtkins@discussions.microsoft.com> wrote in message
news:B75D59E3-959A-4F37-BC27-8DD9B5A0715E@microsoft.com...
|