Hello Mary, Romeo Try the following:
1. Create a SqlDatabase for Master, that is not under a component (so its just a reference) 2. Under you component for the target database, but not under the SqlDatabase entry for that database, add a SqlString which is run against Master, executed on uninstall. Use a SqlString because properties are expanded there. and make the Sql statement if ([DROPDB]='1') drop database [APPDB] 3. Then have you actual database entry, with DropOnUninstall=no The script is run inconjunction with the component being install or uninstalled but is run against master so that the target db is not "in use", it allows you to embed properties in the sql string. See below (this was adapted from something else where I use a similar technique so be aware it is not tested). <!-- Database Locator for Master --> <SqlDatabase Id="sqlserver_Master" Database="master" Server="[BAYDBSERVER]"/> <DirectoryRef Id="TARGETDIR"> <Component Id="CreateDB" Guid="448CEEAB-ADF4-43ED-0021-001143F0301B" DiskId="1"> <SqlString Id="DropDB" SqlDb="sqlserver_Master" ExecuteOnUninstall="yes" ContinueOnError="no" SQL="if ([DROPDB]='1') drop database [APPDB]" Sequence="100000"/> <SqlDatabase Id="DBSQL1" CreateOnInstall="yes" ConfirmOverwrite="yes" DropOnInstall="no" ContinueOnError="no" Database="[APPDB]" DropOnUninstall="no" Server="[DBSERVER]"> Regards Michael ________________________________________ From: Maryann Fernandes [itsmary...@gmail.com] Sent: Friday, 12 June 2009 6:35 PM To: wix-users@lists.sourceforge.net Subject: [WiX-users] Drop SQL Server database during uninstall Hi, I want to do a similar thing. I want to provide an option for deleting database during uninstallation. I added a checkbox to prompt the user, and bound the checkbox to a property, but I don't know how to drop the database if the property is true. The "droponuninstall" attribute on SqlDatabase does not take a property as its value. I thought of using a sql script to drop the database. But there is no <condition> child allowed for <SqlScript>. Even the inner text does not tkae a condition. Please help. Regards, Maryann Romeo S. wrote: > > Hi, > > Our package creates a database during installation and we only want to > drop the database during uninstall when the PROPERTIES DROPDB="1". > > What i did was i've created a component: > <Component Id="createDB" Guid="8D0757C0-B204-4A99-8FA1-4F3235FA2CAF"> > <CreateFolder Directory="INSTALLDIR" /> > <sql:SqlDatabase Id="createSqlDB" CreateOnInstall="yes" > Server="[SQLSERVER_SERVER]" Database="[SQLSERVER_DATABASE]"> > <sql:SqlScript Id="createScript" ExecuteOnInstall="yes" > ContinueOnError="no" BinaryKey="create_DB.sql"/> > </sql:SqlDatabase> > </Component> > > And then i created another database for dropping the database: > <Component Id="dropDB" Guid="D32A0748-A505-45B4-B419-BF21C71FF0B6"> > <CreateFolder Directory="INSTALLDIR" /> > <sql:SqlDatabase Id="dropSqlDB" DropOnUninstall="yes" > Server="[SQLSERVER_SERVER]" Database="[SQLSERVER_DATABASE]" /> > <Condition><![CDATA[DROPDB="1"]]></Condition> > </Component> > > What is the right way to do this? All we want is drop the database on > uninstall only if DROPDB="1". Thank you in advance. > > Regards, > Romeo ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users