I have an windows application developed in C#, I need to install it on a PC which will just have the Operating System and .Net Framework installed. Now I have to give an option to install SQL Server 2008 R2 Express edition on that PC, using this windows application. I have coded for installing/uninstalling a windows service, but struck with sql server installation. could someone help me out in doing this.
相关问题
- Sorting 3 numbers without branching [closed]
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Graphics.DrawImage() - Throws out of memory except
- Difference between Types.INTEGER and Types.NULL in
You can use msiexec.exe. You can simply install an MSI by passing the MSI path. Using command you can set whether to show UI during the installation or make it a silent installation,
string installCommandString = "/i {0} /qn";
C# code
If you are using the standard MSI installer, built into Visual Studio then there is an option to set pre-requisites.
Near the bottom there is an option for SQL Server Express and you can specify where to get the components from - vendor, or from a location on your servers.
Follow the guidelines in How to Embed SQL Server Express in an Application. It covers everything you need, including pickiing up the right distribution, choosing an appropriate installation method (wpi vs. setup.exe) and how to configure the installation. the wiki even has a C# code on how to detect a previous Express instalation, how to invoke the WPI (Web Platform Installer) for SQL Express from C#:
or using the "wpi://" URL handler:
or using the Web App Galery:
and, finally, using the SQL Express setup (recommended for advanced configuration):
and it has the full list of setup parameters.