Install MSDE as a part of setup?
Hi,
I need to install MSDE as a part of setup of my application. Setup must check if MSDE/SQL server are installed on local PC. If yes, setup must skip intalling of MSDE, otherwise it will instal MSDE in the background.
How to do that?
Thank's
Alexei
Hi Alexei
There are three ways to check whether or not MSSQL is installed
1. Try connecting to the database via SqlConnection or OleDbConnection.. though this will stillr eturn an error if the server is stopped, so not your best option.
2. Using SQLDMO, this is probably the most preferable out of the three (IMO), as you can do a lot more with SQLDMO than just just check for the existance of MSSQL. Now a word of warning, you will need to install the SQLDMO dll before you try to check, because it will not exist on the machine, unless MSSQL is already installed on it ;)
3. Search the registry; you can search the registry keys for 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup' and see if it exists ;)
Ok, now you have determined whether you want to install MSDE or not.
Microsoft used to include the Merge Modules for MSDE in previous versions, so you will have to use setup.exe and if you like your own setup.ini with your custom settings in it.
Ok, sounds simple.. right? Well if you check the newsgroups people ahve had all sorts of trouble executing the MSDE setup.exe from .NET.. with setup.exe just hanging.
Now if I recall correctly, the problem was with .NET waiting for setup.exe to issue an exit code and setup.exe waiting on .NET to go idle... 9I maybe slightly wrong with this).
However a very clever person 9whos name escapes me right now) figured out how to fix this.. with just a few simple lines... that had many developers (myself included) tearing out their hair.
[CODE]
string parameters = @"/settings setup.ini";
Process msde = new Process();
msde.StartInfo.FileName = Application.StartupPath + @"\MSDE_SETUP\setup.exe";
msde.StartInfo.Arguments = parameters;
msde.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
msde.EnableRaisingEvents = true;
msde.Start();
msde.WaitForInputIdle();
msde.WaitForExit();
msde.Close();
[/CODE]
Hope this has been of help to you.
Al