Anything They Can Do Why can't you?

5Oct/091

Application Name in .net Connection Strings

Ever want to check to see how data got into your database? I know that at times I will fire up SQL Managment Studio and make some changes when I need to we all do it. Here is a nice little trick that you can put in a trigger on sensitive tables to record what application told the database to update/insert. the below will yield you what ever value you put in the Application Name parameter in the connection string. I got in the habit of auto appending this to the connection strings stored in my app.config and web.config files in compiled code so that if I need to I can see what program is connecting and with what credentials.

SELECT APP_NAME()

Go ahead load up SQL Server Managment Studio and run that query you should get "Microsoft SQL Server Management Studio - Query"

Tagged as: , , 1 Comment
5Oct/090

Silverlight ComboBox Strong Typed Selected Object

For those of you that use Silverlight and the built in ComboBox here is something that works a little cleaner than the default casting of the SelectedItem on a ComboBox. I am a big fan of extension methods and I plan to post a lot about them in the future so I decided to start with something small.

public static T GetSelectedObject(this ComboBox cb) where T:class
{
    return cb.SelectedItem as T;
}