Book Image

WiX Cookbook

By : Nicholas Matthew Ramirez
1 (1)
Book Image

WiX Cookbook

1 (1)
By: Nicholas Matthew Ramirez

Overview of this book

WiX is a dialect of XML used to make installers for Windows. Its declarative style avoids the complexity and limitations of procedural code, providing you with everything you need to package up an entire application into a single MSI file. This book gives you a good overview of WiX's capabilities to develop your own installer packages with functionalities beyond those available in Windows Installer. In the recipes of this book, you will see ways in which WiX can cut down on your installation time and help you streamline your deployment processes. You will see how to make customized installer UIs, write custom actions, create shortcuts, and also set your application as the default for a file type.
Table of Contents (15 chapters)
14
Index

Inserting data into a database table


During the installation, you may decide to populate your database tables with some seed data. For example, you may have a list of U.S. states in which you do business that you'd like to add as static data. In this recipe, we will create a database, add a table to it, and then insert new rows into that table.

Getting ready

Create a new setup project and call it InsertingDataInstaller.

How to do it...

Include an INSERT statements in a SqlScript element to add rows of data to a database. The following steps show how to do it.

  1. Add SqlExtension to the project by right-clicking on the References node in Solution Explorer and selecting OK after navigating to Add Reference... | Browse | WixSqlExtension.dll | Add.

  2. Add the SqlExtension namespace to the Wix element:

    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"  
    xmlns:sql="http://schemas.microsoft.com/wix/SqlExtension">
  3. We're going to store all our SQL commands in a file. So, use Notepad to create a file...