Can instance of Sql Server be created dynamically along with installation?
My friend told me that their company has created one software which downloads SQL server on the fly while installing the exe and even installs the SQL server and gives name to the instance with some default name. Actually they have application which is in开发者_C百科dependent and the SQL server is installed dynamically. Data is not stored centrally on the server. I had no clue how they must have done this. Is this really possible? How can we do this?
It's not too hard I think. First use HttpWebRequest
class to donwload the installer from Microsoft and then follow the install guideline for installing SqlServer from the command prompt by starting it as a separate process and pass the appropriate parameters. This is when you want to do it from your software.
Otherwise it depends on the installer you use - but most of them can be scripted to download files and executed processed with given command line parameters.
Yes you can do so, by setting the prerequisites for your installer.
Add a "setup And Deplyoment" Porject type, in the Solution Explore Select the Setup project and right click to open the context menu.
Then click "Properties" menu item. This will open "Setup Property Page" in that click on the "Prerequisites" button, which will open a new dialog window, and over there you can select the "SQL server" as a prerequisites for your installation.
You can add the installer class in the deployment project like below highlighted.
Add Sql server exe in the deployment project.
Add the commit event in this class like below.
public override void Commit(IDictionary savedState)
{
try
{
base.Commit(savedState);
Process p = System.Diagnostics.Process.Start("Your path of sql server exe");
if (!p.HasExited)
{
p.Refresh();
}
while (!p.WaitForExit(1000)) ;
}
catch (Exception)
{
throw new InstallException();
}
finally
{
startuppath = null;
}
}
You can also try using the prerequisites of sql server in your deployment project according to the below prerequisites dialog box.
I believe sql server installs using a msi.
MSIs can be run from the command line so its possible that they are installing the msi with the quiet switch and providing all of the required parameters that would normally be provided in the setup UI.
You can automate almost every installation. You can have a look at MSDN Library. They are probably downloading the Express edition of the sql server - I think with every other edition there are licensing issues.
This method is called Silent Install or Unattended Installation. See here a complete tutorial about this.
精彩评论