Can Wix silently overwrite a database

Perhaps Wix can prompt / inform the user that the database exists and give them the option to overwrite or cancel the installation. Unfortunately, the user cannot specify "do not overwrite" and continue with the installation.

Hence, can Wix silently overwrite the database? If the database is present, just ignore and transfer the next command.

If not, is there any other way to make sure that the reinstallation needs to be done and the database is already in place?

My current Wix snippet looks like this:

<Fragment>
    <ComponentGroup Id="COMPG_MyProductDatabase" Directory="TARGETDIR">
      <Component Id="COMPG_MyProductDatabase.sql" Guid="{...}">
        <File Id="FILE_MyProductDatabase.sql" Source="..\MyProduct.Cache.Database\MyProduct.Deployment.sql" Name="MyProduct.Deployment.sql" KeyPath="yes" Checksum="yes"/>
      </Component>

      <Component Id='COMP_MyProductDatabase' Guid='{...}'>
        <CreateFolder/>
        <sql:SqlDatabase Id='DB_MyProductDatabase' Database='MyProduct' Server='[PROP_DATABASESERVERNAME]'
          CreateOnInstall='yes' DropOnUninstall='no' ContinueOnError='yes' ConfirmOverwrite='yes'>
          <sql:SqlScript Id='SQL_MyProductDatabase' BinaryKey='FILE_MyProductDatabase' ExecuteOnInstall='yes' />
        </sql:SqlDatabase>
      </Component>
   </ComponentGroup>
    <Binary Id='FILE_MyProductDatabase'  SourceFile='..\MyProduct.Cache.Database\MyProduct.Deployment.sql' />
</Fragment>

      

+3


source to share


1 answer


Move database creation into your SQL script, then use SQL statements to execute conditional logic. Modify the SqlDatabase element to connect to "master" for this to work.



+2


source







All Articles