- Changing the database instance name, the default instance name is SQLExpress and cannot be changed (it is restricted)
- Cannot change the SQL user and password
- Thus this makes SQL Express application hard to be configured automatically, and it causes programmer must do some manual configuration.
In this Tutorial, I have a class name BusinessSQLEXPRInstaller, to use it as installer
- First build your windows form application and add app.config entry
<appSettings>
<add key="IsInstall" value="0"/>
<add key="IsRestart" value="1"/>
</appSettings>
Add both isinstall and isrestart key in app.config, and let the value like that as default
in your windows form, there must be a start up form, in this start up form constructor add
JohnKenedy.BusinessSQLEXPRInstaller _ins = new JohnKenedy.BusinessSQLEXPRInstaller("<Installation Display Name>", "localhost", "<New database instance name>", "<new database name>", "<database password>", "<database backup filename>");
if (_ins.IsDone == false) _ins.ShowDialog();
if (_ins.IsRestart == true)
{
Application.Exit();
this.Close();
return;
}
Change <..> to match with your value.
- After your project is ready, create setup and deployment application
- Then Download SQL Express for free at http://download.microsoft.com/download/e/a...e/SQLEXPR32.EXE
- use command line to go to the exe folder and type : SQLEXPR32.EXE /x
- nows all the files contain in exe resources, will be extracted, and add these extracted files into your Setup and Deployment Application Folder\SQLEXPR2005 folder (create this new folder)
- add your database backup filename (for example mydb.bak which is created from SQL Server Enterprise manager or management studio) and put it in this folder too
- Build your setup and deployment project
The resulted setup.exe now includes the SQLExpress that can be installed by your application using BusinessSQLEXPRInstaller class.
This helps you automate several things
- restore your database to the client without user configuring
- install the database engine without user knowing
- as developer you know the database engine username and password and can be controlled by you as developer
- User does not need to know programming languages, they just click and install, and no need to understand how to setup your application to connect with the database.


