суббота, 9 февраля 2008 г.

Usage & redistribution of SQLDMO in .NET

Hi all!

Recently I had the following problem. I was writing a program to install a complicated ASP.NET website. This program was written in .NET, and it included a form showing all available on the network SQL servers. As soon as user picks up an SQL server, program should check if we can log on to the server and if the server supports SQL Server authentication (i.e. mixed authentication is on). If it's not enabled, then we had to enable it and restart SQL server.

For all this stuff I have used SQL-DMO objects. While this really worked great on my machine, it didn't do so on a clean windows installation, because, ahh... sure, DMO was not installed. While googling this for a bit, I have decided to create a small installation package for DMO, which would be installed at the very beginning of the installation, while "Installation wizard is checking your computer configuration..." screen.

I have used this article as a reference on how to create it: http://support.microsoft.com/default.aspx?scid=kb;EN-US;248241.

After several buggy setups, I finally was able to create a good one.

You can run it from your application as "dmo.msi /quiet", and it will install and register DMO correctly on the computer. Please make sure that before you run the package you have checked, that there is no DMO installed already. To do that, you can use the following C# code:

try
{
SQLDMO.SQLServer2 srv = new SQLDMO.SQLServer2();
}
catch
{
Process p = Process.Start("dmo.msi", "/quiet");
p.WaitForExit(30000);
}

If you have any questions on how I did that, or you are having problems with the package, please contact me using Centur IT programmer's pages. You can find an email address you should use for the contacts there.

Usually I get around 10-15 emails per day, so I will (hopefully) reply the same day I receive an email.

Happy Programming!

Alexey Stoletny

2 комментария:

Alexey комментирует...

Cool.
I tested this functionality, and it worked! Nice job.

Jesus комментирует...

thanks X 1000