Wix SqlDatabase creation of 2014 LocalDb Error

1

I have a Wix Toolset project that needs to install a database into an existing install of SqlServer 2014 LocalDb and I've not been successful at all. I've searched extensively on SO as well as other sites for examples or suggestions that might be applicable. So far, I've found nothing that works in my project.

SqlServer Local DB was already installed on the system and can be access from SQL Mgmt Studio. All of the system databases appear as expected and I'm able to create a new database in Mgmt Studio.

The text file that I include as a test does install correctly in the expected folder.

The error that I am receiving varies depending on which options I define within the SqlDatabase element.

From the installer log:
Action 11:46:34: CreateFolders. Creating folders
CreateFolders: Folder: C:\Check\Database\
CreateFolders: Folder: C:\Check\Database\
Action 11:46:34: InstallFiles. Copying new files
InstallFiles: File: TestFile.txt, Directory: C:\Check\Database\, Size: 19
Action 11:46:34: CreateDatabase. Creating Databases
CreateDatabase: Error 0x80004005: failed to create SQL database but continuing error: unknown error, Database: Check
Action 11:46:51: RegisterProduct. Registering product

The wxs file for this installation:

<?xml version="1.0" encoding="UTF-8"?>
<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'>
<Product Id="*" Name="Ach Check Database Installation" Language="1033" Version="1.0.0.0" Manufacturer="ACH Solutions" UpgradeCode="3828eaf7-528f-4006-9169-27bed44e79fe">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <MediaTemplate EmbedCab="yes"/>
    <Feature Id="CheckDb" Title="Check Database" Description="The Check Database" ConfigurableDirectory="INSTALLDIR" Level="1">
        <ComponentGroupRef Id="DatabaseComponents" />
    </Feature>
    <UIRef Id="WixUI_Mondo" />
</Product>  
<Fragment>
  <Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="INSTALLDIR" Name="CheckDir" >
      <Directory Id="DatabaseFolder" Name="Database" />
    </Directory>
  </Directory>
</Fragment>
<Fragment>    
    <ComponentGroup Id="DatabaseComponents" Directory="DatabaseFolder">
        <Component Id='SqlComponent' Guid='53234257-65F1-4D58-B2CA-90308EC102FF'>
            <CreateFolder />
            <File Id="file_TestFile.txt" Source="E:\TestFile.txt"/>
        </Component>
        <Component Id="sql_SqlDatabase" Guid="B4D9CB63-B740-4860-89B6-1209D9A1A18E">
             <CreateFolder/>
             <sql:SqlDatabase Id='SqlDatabase'
                    Database='Check'
                    CreateOnInstall='yes'
                    Server='localhost\(localdb)\MsSqlLocalDb'
                    DropOnUninstall='no'
                    ContinueOnError='yes'>
                <sql:SqlFileSpec Id='sql_CheckDatabase' Filename='CheckDatabase.mdb' Name='CheckDatabase' Size='30MB' />
               <sql:SqlLogFileSpec Id='sql_CheckDatabase_Log' Filename='CheckDatabase_Log.ldb' Name='CheckDatabaseLog' Size='3MB' />
            </sql:SqlDatabase>
        </Component>      
    </ComponentGroup>
</Fragment>  
</Wix>

Has anyone run into this problem or something similar before? What was the solution?

I welcome any suggestions that might assist in this.

Thanks,
Eugene

wix
localdb
asked on Stack Overflow Oct 23, 2015 by Eugene

2 Answers

0

I believe the Server attribute should be just '(localdb)\MsSqlLocalDb'.

Also make sure the LocalDB instance exists by the time you run the installer and that it's shared with the user under which the installer is running. For testing purposes you can also try to use named pipe instead of server name. To get the name of the instance's pipe run the following command in the command line:

sqllocaldb info MsSqlLocalDb
answered on Stack Overflow Oct 24, 2015 by rocky
0

WiX doesn't support localdb connections.

https://github.com/wixtoolset/issues/issues/4957

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/b5c9a1fa-75fc-41f2-a5d3-4b2b6ed4ebde/localdb-problem-unable-to-connection-via-localdbv110-but-can-via-named-paipes

Someone would have to update dutil to use the latest SQL Server Native Client and it seems in 7 years no one has.

The alternative is to write your own custom actions for SQL processing. I have some that I can provide if you email me a request.

answered on Stack Overflow Feb 24, 2019 by Christopher Painter

User contributions licensed under CC BY-SA 3.0