Here's an article on how to use SQL-DMO in .NET