We are using the following code to change the SQL Server authentication from Windows mode to mixed mode.
query.CommandText = "EXEC xp_instance_regwrite 'HKEY_LOCAL_MACHINE', 'Software\Microsoft\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQLSERVER', 'LoginMode', REG_DWORD, 2"
query.CommandType = CommandType.Text
query.ExecuteScalar()
During the execution we get the following error.
RegCreateKeyEx() returned error 5, 'Access is denied.'
We could change the authentication mode manually. However we need to do this work programmatically.
Help needed.