Using Wix 3.7, I want to create a database if the CREATEDATABASE parameter is 
set on command-line, but then always execute the create login SQL command 
(which may fail because the login already exists).  So my Wix code looks 
something like this:

    <ComponentGroup Id="SqlComponents" Directory="INSTALLFOLDER">
      <Component Id='InstallDatabase' Win64="$(var.Win64)" Guid='{Guid}' 
KeyPath='yes'>
        <Condition>CREATEDATABASE</Condition>
          <sql:SqlDatabase Id='SqlDatabaseCreate' Database='[SQLDATABASE]' 
User='SQLUser' Server='[SQLSERVER]'
            CreateOnInstall='yes' DropOnUninstall='no' ContinueOnError='no'>
            <sql:SqlScript Id='AspNetSchema' BinaryKey='AspNetSchema' 
ExecuteOnInstall='yes' Sequence='10'/>
          </sql:SqlDatabase>
      </Component>

      <Component Id='SetDatabasePermissions' Win64="$(var.Win64)" Guid='{Guid}' 
KeyPath='yes'>
        <sql:SqlDatabase Id='SqlDatabaseSet' Database='[SQLDATABASE]' 
User='SQLUser' Server='[SQLSERVER]'
          CreateOnInstall='no' DropOnUninstall='no' ContinueOnError='no'>
          <sql:SqlString Id='CreateLogin' ExecuteOnInstall='yes' 
ContinueOnError='yes' SQL='create login [ACCOUNT] from windows' Sequence='20' />
      </Component>

    </ComponentGroup>

Since there is no sql:SqlDatabaseRef statement, I had to created two 
sqlDatabase statements, under two Components.  The compiler forces me to have 
two different SqlDatabase Id's, which is fine.  But it won't let me do this 
because my second SqlDatabase statement has no 'yes' to CreateOnInstall, 
DropOnInstall, etc.

What is the proper way to do this?



------------------------------------------------------------------------------
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122812
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to