Through some tinkering I found that I simply had to pull the
<sql:SqlDatabase> outside of the Component tag, leaving everything else as
I originally had it.

Here is how I did it in case someone needs to know:

<Fragment>
    <Binary Id="CreateUpsizingDatabase" SourceFile="SqlScripts/00A_Create
Database DC.sql" />

    <util:User Id="SQLUser" Name="[SQLUSER]" Password="[PASSWORD]" />

    <sql:SqlDatabase Id="SqlDatabase" Database="[SQLDATABASE]"
Server="[SQLSERVER]"
                                  User="SQLUser" />
    <DirectoryRef Id="INSTALLFOLDER">
      <Component Id="SqlComponent"
Guid="15CCE46E-8EA5-42CA-80C5-AC3DB30A9716">
      <sql:SqlScript Id="CreateDatabases" SqlDb="SqlDatabase"
                             ExecuteOnInstall="yes"
BinaryKey="CreateUpsizingDatabase" />
          <CreateFolder/>
      </Component>
    </DirectoryRef>

</Fragment>

Brian

If you can't explain it simply, you don't understand it well enough.  -
Albert Einstein

On Tue, Oct 14, 2014 at 1:02 PM, Brian Enderle <bria...@gmail.com> wrote:

> Thanks, I see that specifying under a Component forces the install.  I
> have removed the component tag and am now trying to call it like so:
>
> <Fragment>
>     <Binary Id="CreateUpsizingDatabase" SourceFile="SqlScripts/00A_Create
> Database DC.sql" />
>
>     <util:User Id="SQLUser" Name="[SQLUSER]" Password="[PASSWORD]" />
>     <sql:SqlDatabase Id="SqlDatabase" Database="[SQLDATABASE]"
> Server="[SQLSERVER]"
>                                  User="SQLUser" >
>       <sql:SqlScript Id="CreateDatabases" ExecuteOnInstall="yes"
> BinaryKey="CreateUpsizingDatabase" />
>     </sql:SqlDatabase>
>
> </Fragment>
>
> But doing this results in the following error when i try to build the
> project:
>
> Error 410 The sql:SqlScript element cannot be specified unless the
> element has a Component as an ancestor. A sql:SqlScript that does not have
> a Component ancestor is not installed.
>
> Unfortunately all the examples I can find on this subject show the
> SqlDatabase under a Component tag so I am not sure what I am doing wrong
> here.
>
> Brian
>
> If you can't explain it simply, you don't understand it well enough.  -
> Albert Einstein
>
> On Tue, Oct 14, 2014 at 11:44 AM, Rob Mensching <r...@firegiant.com> wrote:
>
>> http://wixtoolset.org/documentation/manual/v3/xsd/sql/sqldatabase.html
>>
>> Nesting SqlDatabase under a Component element will result in a
>> SqlDatabase being installed to the machine as the package is
>> installed.Nesting SqlDatabase under Product, Fragment, or Module results in
>> a database "locator" record being created in the SqlDatabase table. This
>> means that the database itself is neither installed nor uninstalled by the
>> MSI package. It does make the database available for referencing from a
>> SqlString or SqlScript record. This allows MSI to install SqlScripts or
>> SqlStrings to already existing databases on the machine. The install will
>> fail if the database does not exist in these cases.
>>
>>
>> _____________________________________________________________
>>  Short replies here. Complete answers over there:
>> http://www.firegiant.com/
>>
>>
>>
>> -----Original Message-----
>> From: Brian Enderle [mailto:bria...@gmail.com]
>> Sent: Tuesday, October 14, 2014 7:33 AM
>> To: WiX Users
>> Subject: [WiX-users] Running SQL script without creating a database
>>
>> I have a script file that creates a couple of databases.  I am trying to
>> run this script from WiX as follows (parameters captured from GUI):
>>
>> <Fragment>
>>     <Binary Id="CreateUpsizingDatabase"
>>                  SourceFile="SqlScripts/00A_Create Database DC.sql" />
>>
>>     <util:User Id="SQLUser" Name="[SQLUSER]" Password="[PASSWORD]" />
>>
>>     <DirectoryRef Id="INSTALLFOLDER">
>>       <Component Id="SqlComponent"
>> Guid="15CCE46E-8EA5-42CA-80C5-AC3DB30A9716">
>>         <sql:SqlDatabase Id="SqlDatabase" Database="[SQLDATABASE]"
>>                                      Server="[SQLSERVER]"
>> CreateOnInstall="yes"
>>                                      DropOnUninstall="no" User="SQLUser"
>>                                      ContinueOnError="no" />
>>         <sql:SqlScript Id="CreateDatabases" SqlDb="SqlDatabase"
>>                                ExecuteOnInstall="yes"
>> BinaryKey="CreateUpsizingDatabase" />
>>         <CreateFolder/>
>>       </Component>
>>     </DirectoryRef>
>>
>> </Fragment>
>>
>> When I run this WiX wants to create a database for me using the
>> parameters specified.  Is there a way to NOT create the database and still
>> run the
>> script?   I tried specifying an existing database but got an error.  I
>> also
>> set 'CreateOnInstall' & 'DropOnUninstall' to NO but got a build error
>> that "one of the following attributes has to be specified" (I assume this
>> means one must be set to YES).
>>
>>
>> Brian
>>
>> If you can't explain it simply, you don't understand it well enough.  -
>> Albert Einstein
>>
>>
>> ------------------------------------------------------------------------------
>> Comprehensive Server Monitoring with Site24x7.
>> Monitor 10 servers for $9/Month.
>> Get alerted through email, SMS, voice calls or mobile push notifications.
>> Take corrective actions from your mobile device.
>> http://p.sf.net/sfu/Zoho
>> _______________________________________________
>> WiX-users mailing list
>> WiX-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/wix-users
>>
>
>
------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to