The provider is unable to determine identity for newly inserted rows

The provider is unable to determine identity for newly inserted rows

Post by Max » Thu, 18 Jan 2001 00:06:22



Problem:

-I have a table with Identity field
-In one function i call _Recordset::AddNew()/Update to insert a new field.
(I open a recordset with adCmdTable)
-In another function i call _Connection::Execute() to DELETE some rows.

In all functions i open and close connections and recordsets.

Only when i call function that Insert a new record after calling a function
that deletes records. It generates an Exception:

The provider is unable to determine identity for newly inserted rows
(-2147217893)

___________________________________
Thank you for resolving my problem

 
 
 

1. 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

2. Linking tables across databases

3. SQL Performance Info

4. Identity cannot be determined for newly inserted rows

5. Window won't minimize

6. Restoring using Legato and onbar

7. Determining newly inserted identity value in DB2 v6

8. Identify cannot be determined for newly inserted rows

9. How to get Identity column values for newly inserted row

10. get back the identity of a newly inserted row thru ODBC

11. Getting IDENTITY value of newly inserted row