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.
- 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. - Add the
SqlExtension
namespace to theWix
element:<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:sql="http://schemas.microsoft.com/wix/SqlExtension">
- We're going to store all our SQL commands in a file. So...