[wix-users] Override Sql DB in WiX

James Buchan James.Buchan at servelechsc.com
Wed Mar 7 09:15:11 PST 2018


You probably don't want the line 'Use MsiTestDb' line in your script.

James

-----Original Message-----
From: wix-users <wix-users-bounces at lists.wixtoolset.org> On Behalf Of Ven H via wix-users
Sent: 07 March 2018 17:01
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Cc: Ven H <venh.123 at gmail.com>
Subject: [wix-users] Override Sql DB in WiX

I have an SQL script CREATE_TABLE.sql which has the following statement

use MsiTestDB
go

if not exists( select 1 from information_schema.tables where table_name = 'EMPLOYEES' ) begin create table dbo.EMPLOYEES ( EMP_ID INT NOT NULL, EMP_NAME NVARCHAR(100) NOT NULL
)
end
go

I have the following markup in my wxs file.

 <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="
http://schemas.microsoft.com/wix/UtilExtension" xmlns:sql="
http://schemas.microsoft.com/wix/SqlExtension">
<Fragment>

    <util:User Id="SQLUser" Name="[SQLUSER]" Password="[SQLPASSWORD]" />
    <Binary Id="binCreateTbl" SourceFile="CREATE_TABLE.sql" />

    <Component Id="dbComp" Guid="329600D4-F7F4-4038-9963-4A4C25D5AE7F"
Directory="INSTALLFOLDER" KeyPath="yes">

      <sql:SqlDatabase Id="msiTestDB"
Database="[SQLDB]"
Server="[SQLSERVER]" Instance="[SQLINSTANCE]"
CreateOnInstall="yes"
User="SQLUser" />

        <sql:SqlScript BinaryKey="binCreateTbl" Id="script_CreateTbl"
ExecuteOnInstall="yes" ContinueOnError="no" SqlDb="msiTestDB"  />

    </Component>
</Fragment>
</Wix>

 The properties (within square brackets) are provided from the UI. The SQL Script has a "Use MsiTestDB" statement. So, even if I pass a new and different value for the SQLDB property from the UI, it always executes and creates the table in the MsiTestDB. Is it possible in WiX to workaround or override this behavior?


Regards,
Venkatesh

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/



More information about the wix-users mailing list