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)

10 Feb 2015

Edit Web.Config from File Explorer in Windows 7 / 8 / 2012 - Read Only for Administrator

Don't you hate that UAC thing whereby you can't edit your site's web.config file directly from File Explorer? It lets you open it in notepad and then won't let you save. Even though you're an Administrator! ANNOYING!

It's because of the default Access Control List on the Inetpub folder. When you edit any file under that folder, Windows busts you down to User level permissions, even though your user is a member of the Administrators group.

A quick fix is to grant full access permissions over Inetpub to your explicit user account. Run this in an elevated (Run As Administrator) command prompt (Note you don't need to type your actual username in here, the environment variables will be interpolated for you automatically):

icacls %systemdrive%\inetpub /grant  %userdomain%\%username%:(OI)(CI)(F) /grant %userdomain%\%username%:F
If I helped you out today, you can buy me a beer below. Cheers!