Book Image

WiX Cookbook

By : Nicholas Matthew Ramirez
1 (1)
Book Image

WiX Cookbook

1 (1)
By: Nicholas Matthew Ramirez

Overview of this book

Table of Contents (20 chapters)
WiX Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
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...