16 Feb 2015

Get Inserted ID from SQLOLEDB ADO Recordset.AddNew with SQL Server

Migrating a legacy ASP site to SQL Server, had a prob whereby lots of code that previously used RecordSet.AddNew() with RecordSet.Update(), and then immeditately retrieved the inserted ID from the RecordSet, suddenly failed to get the inserted ID.

The solution was to set the RecordSet CursorType to adOpenKeyset (constant value 1)

No comments:

Post a Comment

Comments are very welcome but are moderated to prevent spam.

If I helped you out today, you can buy me a beer below. Cheers!