Click here to Skip to main content
Click here to Skip to main content

.NET Installer that automatically installs MSDE

By , 26 Jul 2008
Rate this:
Please Sign up or sign in to vote.


Often programmers want to build a single installer package that can install the application along with prerequisites and database. Fortunately for database, programmers can use MSDE which can be distributed along with your application, but MSDE lacks user interface so to configure it often we need to use command line.


This is the scenario:

  1. A programmer wants a single package that automatically installs .NET Framework and then installs MSDE and uses the database for the application that a programmer writes.
  2. In this tutorial, the installation will create a new database instance, with a name specified by the programmer, and it can detect whether this instance exists and as for removal, so for safety programmer just create a unique database instance name.
  3. The library then automatically attaches the database to this newly installed database instance. First I have written two projects which are required to be included in your solution. First is JohnKenedy.DataAccess and second is JohnKenedy.DataAccessModule. This is because the installation code is coming along with this library.
  4. The goal of this project is, user gets the installation files, double clicks the EXE, and clicks next and next following the instruction without the need to understand how to connect database, the database name, username, password and so on, user just clicks next and next, the application will install the .NET prerequisites, the database, and attach the database that programmer has created all automatically, and the application that programmer writes, runs and connects to the database without user knowing how to configure them. What user needs to know is only how to use the application that the programmer writes.


  1. Download the sample code I attach and extract it to D:\Software Pekerjaan\Makanan (I use for this example.)
  2. Assume the MenuMakanan project is the Windows Application project that you are creating and which is going to be deployed. From this project, add reference to library named JohnKenedy.DataAccess.

  3. Download MSDE by clicking here. Double click the .exe and by default it will extract to your C:\sql2ksp3. Copy the extracted contents to MenuMakanan project bin\debug\MSDE2000 folder.
  4. Detach your application's database to become MDF file, and copy the MDF file only to MenuMakanan project bin\debug\MSDE2000 folder. For this example, it is Food_Data.MDF which is contained in the download for example.
  5. In your application (MenuMakanan), add an Application Configuration file or app.config (in this sample, it already exists), and create two new keys in AppSettings section, read App.Config in sample for more information. Remember to set IsInstall=0, and IsRestart=0 as follows, because this will tell your application to install before running, IsRestart will be 1 if it is finished installing and requires to restart your computer so that the newly installed MSDE service is running.
    <add key="IsInstall" value="1"/>
    <add key="IsRestart" value="0"/>    
  6. In your startup Form or form that is first run when application starts in this example is Login.cs, in the constructor after InitialilzeComponent, add codes that look like this:
    public Login()
        Installation _ins = new Installation(
            "Food", "JOHN", "MenuMakanan", "Food", 
        if (_ins.IsDone == false) _ins.ShowDialog();
        if (_ins.IsRestart == true)


  3. Third is MenuMakanan, which is the new database instance that will be installed, this is similar with (local)\SQLExpress database instance that Microsoft installed when we install VS 2005, though this one is MSDE one. This name must be unique, and this database instance will only contain one database name which will be defined in the fourth parameter, and be used by your application only.
  5. Fifth is JOHNKENEDYDAL, which is the sa password for the newly installed MSDE, this password is required when you use Enterprise Manager (SQL 2000) to connect to the database instance.
  6. Food_Data.MDF is your MDF file name, that is stored in MenuMakanan project bin\debug\MSDE2000 folder. You can change this as it suits you.



Create Setup and Deployment Package

  1. Create a new Setup and Deployment project, in this sample it already exists with name SetupMakanan.
  2. In the application folder, create a new folder name MSDE2000, and inside this folder create three folder names Msi, MSM, and Setup. Then inside MSM folder, create a folder names 1033. This structure is the same with the MSDE extracted folder earlier in Step 3, we then add files to these folders MSDE2000, Msi, MSM, 1033, and Setup folder according to the MSDE extracted folders.
  3. Add Food_Data.MDF to MSDE2000 folder, because the Installation class will look for the filename in this folder. After step two and three, it will look like:

    Click here for a bigger image



  5. And then select the second radio button. Download prerequisites from the same location in my application. Click OK, and save.

  6. Build your whole solution, and then build SetupMakanan project, and you will see in SetupMakanan project debug folder Setup.exe SetupMakanan.msi, and two new folders, one is Windows Installer 3_1 and another is DotNetFX35 which are the .NET prerequisites.



This library is not fully for Installation, instead the library has Data Access feature, which article can be found here.

Installation is one of the features in the library I developed recently. I have tested the Setup package in a computer that never had .NET and database installed, and it did successfully install .NET and MSDE and run the application smoothly.



About the Author

John Kenedy S.Kom
Software Developer (Senior)
Singapore Singapore

Comments and Discussions

GeneralAbout Setup Pinmemberrentcoder20-Mar-09 0:48 
Generaltwo .mdf's Pinmembergrks22-Dec-08 1:49 
QuestionWhy MSDE? PinmemberPaul Conrad27-Jul-08 10:31 
AnswerRe: Why MSDE? PinmemberJohn Kenedy S.Kom27-Jul-08 19:42 
GeneralRe: Why MSDE? PinmemberPaul Conrad27-Jul-08 19:47 
GeneralRe: Why MSDE? PinmemberJohn Kenedy S.Kom28-Jul-08 5:36 
GeneralRe: Why MSDE? PinmemberPaul Conrad28-Jul-08 5:42 
GeneralRe: Why MSDE? PinmemberJohn Kenedy S.Kom28-Jul-08 8:07 



| Advertise | Privacy | Mobile
Web02 | 2.8.140314.1 | Last Updated 27 Jul 2008
Article Copyright 2008 by John Kenedy S.Kom
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid