Posts

Showing posts from 2015

Changing the service account credentials in SQL Server

Image
Like most people, when I first start out setting up something new I take the defaults, and that usually is good enough.  Then down the road, while learning more about how the product works, I discover that the defaults don't cut it in some cases.  Microsoft SQL Server is one example.  Out of the box it defaults to using a local account for its services, "nt service\mssql$instancename".  That works fine until you start doing stuff like replication, mirroring, or interacting with active directory with impersonation.  These functions need a domain account, either to share credentials, or to have access to read active directory. Seems simple enough -- go into the SQL Server Configuration Manager, change the old local account name associated with the service ("nt service\mssql$prod") to a domain account ("ad1\mssql$prod"), and set the account password.  I had previously set up another instance of sql server with this new account, so I know that it was grant

Extending VB.NET objects that are marked as NotInheritable

One of the neat things in VB.Net is something called an "Extension" which allows you to extend the ability of other classes (even if its not possible to subclass the object with inheritance).  For example, in vb6 a lot of times we use Left$() and Right$() to work with strings, and there is a  vb.net  version of these (right() and left()) but it doesn't exist as a method as part of the string itself.  For example, dim MyString as string = "hello" debug.print left(myString,1) <-- prints 'h' but you can use the ToUpper method right off the string itself... debug.print myString.ToUpper <-- the same as ucase(myString) The code below adds 'left' and 'right' extensions to the string class so you can do this .. Imports  Example .Code.StringExtensions debug.print mystring.toupper. left(1)  I also added 'qptrim' as an extension of the trim method that strips out nulls as well.   debug.print mystring.qptrim Below is how you implement e