
Error - The provider is unable to determine identity for newly inserted rows (0x80040E1B)
We are using ADO to access SQL Server 7 from VB6.
We open a keyset recordset
----------------------- code ----------------------------
Dim cnn As New ADODB.Connection
Dim rec As New ADODB.Recordset
cnn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial
Catalog=ADAS;Data Source=RENOIR"
rec.CursorType = adOpenKeyset
rec.CursorLocation = adUseServer
rec.LockType = adLockPessimistic
rec.Open "SELECT * FROM Person", cnn
----------------------- code ----------------------------
THEN WE ADD A ROW
----------------------- code ----------------------------
rec.AddNew
rec("Name") = "TemporaryName"
rec.Update
----------------------- code ----------------------------
THEN WE TRY TO MODIFY A FIELD
----------------------- code ----------------------------
id = rec("PersonId")
rec("Code") = "Code" & id
rec.Update
----------------------- code ----------------------------
at the
rec("Code") = "Code" & id
statement the execution breaks with error
"The provider is unable to determine identity for newly inserted rows
(0x80040E1B)"
IF WE TRY A RESYNC
ADO returns a generic error
"Errors occurred (0x80040E21)"
the only way to continue working on the record is either to issue a bookmark
positioning statement
----------------------- code ----------------------------
rec.Bookmark = rec.Bookmark
----------------------- code ----------------------------
or to reopen the recordset
----------------------- code ----------------------------
id = rec("PersonId")
rec.Close
rec.Open "SELECT * FROM Person WHERE PersonId = " & id, cnn
rec("Code") = "Code" & id
rec.Update
----------------------- code ----------------------------
Even i f I have tiese two workaround I would like to understand the casue of
the problem.
If anyone has any suggestion , I would appreciate hearing back.
Thanks
Lorenzo Saladini