Search This Blog

Tuesday, August 30, 2011

Better way to debug a Windows Service

Using  conditional IF & Debugger.Launch()  to debug a windows Service better and effectively.



Sunday, August 28, 2011

C# Code to add a registry Key

Discovered that adding Registry keys is slightly more complicated using C# vs VB6...
Needed to define a user and registry security to a key change....

public static bool AddRegKey(string keyName, string valueName) { try { string user = Environment.UserDomainName + "\\" + Environment.UserName; RegistrySecurity rs = new RegistrySecurity(); rs.AddAccessRule(new RegistryAccessRule(user, RegistryRights.ReadKey | RegistryRights.Delete | RegistryRights.WriteKey | RegistryRights.ChangePermissions, InheritanceFlags.None, PropagationFlags.None, AccessControlType.Allow)); RegistryKey key = Registry.CurrentUser.OpenSubKey(sDRCRegKey,true); key.SetAccessControl(rs); key.SetValue(keyName, valueName); return true; } catch { return false; } }

Thursday, August 11, 2011

Find Stored Procedures referencing a table

Two ways:

SELECT o.object_id, o.name, m.definition
FROM sys.sql_modules m
INNER JOIN sys.objects o ON o.object_id = m.object_id
WHERE m.definition like '%tableName%'

SELECT p.name, c.text FROM syscomments c
JOIN sys.procedures p ON p.object_id=c.id
WHERE c.text LIKE '%tableName%'
ORDER BY p.name