0

I have a problem creating database with SqlFileSpec and SqlLogFileSpec Filename attribute set under c:\Program Files directory. I also checked that the folder (C:\Program Files\TestProject) already created. Does anyone know how to solve this?

This is the error: Error 26201. Error -2147217900: failed to create SQL database: MyDatabase, error detail: CREATE DATABASE failed. Some file names listed could not be created. Check related errors..

       <sql:SqlFileSpec Id="Mdf" Name="MyDatabase_Mdf" Filename="['INSTALLLOCATION']\MyDatabase.mdf" Size="3072KB" MaxSize="UNLIMITED" GrowthSize="1024KB"/>
                  <sql:SqlLogFileSpec Id="Ldf"  Name="MyDatabase_log"  Filename="['INSTALLLOCATION']\MyDatabase_log.ldf" Size="2048KB" MaxSize="2048GB"  GrowthSize="10%"/>

...


    <Property Id='INSTALLLOCATION'>C:\Program Files\TestProject</Property>

Thanks in advance.

1
  • I am also having a similar issue. But I am using SqlString instead of SqlFileSpec since I may have secondary data files (ndf), in addition to mdf and ndf. SqlFileSpec is allowed only once. But I am not able to get it working even using SqlString and I am also getting the same error. Commented Apr 30, 2018 at 4:53

3 Answers 3

3

The quotes around INSTALLLOCATION should be removed - use just [INSTALLLOCATION]. And make sure the mentioned files (mdf/ldf) are there by the time the action runs. Don't forget that the verbose log is your friend here.

Sign up to request clarification or add additional context in comments.

2 Comments

I tried remove the quotes but still not working. The problem seems to occur only when the path is under Program Files, if i specify the INSTALLLOCATION to C:\MyFolder and the folder exist, it will install properly. Is there any limitation with Program Files. I'm new to wix, how do u ensure the mentioned files (mdf/ldf) are there by the time the action runs? This SqlFileSpec and SqlLogFileSpec should be creating the files when execute or is it copying files?
Do you have the components which actually contain those files as File elements? When it fails, does it throw any message box with the error description? If it does, don't press any button there and go and look to the INSTALLLOCATION whether the files are there
0

Try this

<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 Name='SQL app 1.0' Id='DB501C18-86C7-4D14-AEC0-86416A69ABDE' Language='1033' Codepage='1252'
     Version='1.0.0' Manufacturer='ABC Ltd.'>
            <Package Id='????????-????-????-????-????????????' Keywords='Installer' Description="SQL App 1.0 Installer"
              Comments='Comment.' Manufacturer='ABC Ltd.' InstallerVersion='100'
              Languages='1033' Compressed='yes' SummaryCodepage='1252' />
        <Media Id='1' Cabinet='Sample.cab' EmbedCab='yes' />
        <User Id="MySQLUser" Name="[SQLUSER]" Password="[SQLUSERPASSWORD]"></User>
        <Directory Id='TARGETDIR' Name='SourceDir'>
            <Directory Id='ProgramFilesFolder' Name='PFiles'>
                <Directory Id='INSTALLDIR' Name='TestSQL'>
                      <Component Id="MySqlComponent" Guid="C50999A0-02FD-42d5-9F65-7375318DD328">
                        <SqlDatabase Id="MySqlDatabase" Database="MyDatabase" Server="[SQLSERVER]" Instance="[SQLINSTANCE]"
                            CreateOnInstall="yes" DropOnUninstall="yes" User="MySQLUser" ContinueOnError="yes">
                              <SqlScript Id="CreateDatabase" ExecuteOnInstall="yes" BinaryKey="CreateTablesBin"></SqlScript>
                        </SqlDatabase>
                      </Component>
                </Directory>
             </Directory>
         </Directory>
        <Binary Id="CreateTablesBin" src="CreateDatabase.sql"></Binary>
        <Feature Id='Complete' Level='1' Description="Full" Title="Full Installation">
            <ComponentRef Id='MySqlComponent' />
        </Feature>
    </Product>
</Wix>

CreateDatabase.sql file will contain the script to execute some script, create database, etc.

Comments

0

I've managed to fix my issue by using ".\SQLExpress2012" instead of "[MachineName]\SQLExpress2012" or "[ipAddress]\SQLExpress2012". I can only speculate that by doing the former, you might not be using TCP/IP method of connecting and using named pipes instead.

Also you might want to check your SQL Server Configuration and verify that your server instance support these connection methods.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.