0
votes

I'm trying to install a database with WIX.

I've already installed SQL Server 2008 express on my Windows7 (32 Bit). On this installation, TCP/IP is enabled, SQL Server service is running.

I'm using SQL Server and Windows authentication for SQL Server. I tried both in the code - I added a user in the component.

The code is very basic :

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" 
     xmlns:sql="http://schemas.microsoft.com/wix/SqlExtension">
    <Product Id="*" Name="NewDatabaseInstaller" Language="1033" 
             Version="1.0.0.0" Manufacturer="My Company" 
             UpgradeCode="17ef693b-3ab5-4788-a6b5-70eeabc13497">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <MediaTemplate EmbedCab="yes" />
        <Feature Id="ProductFeature" Title="NewDatabaseInstaller" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
        </Feature>
    </Product>
    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
                <Directory Id="INSTALLFOLDER" Name="NewDatabaseInstaller" />
            </Directory>
        </Directory>
    </Fragment>
    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
            <Component Id="cmpSqlDatabase" Guid="{F950605D-AA59-43E6-AB19-9452F6BEC649}" KeyPath="yes">
                <sql:SqlDatabase Id="sqlDatabase_MyDatabase" Server="localhost"
                     Instance="MSSQLSERVER" Database="MyDatabase"
                     CreateOnInstall="yes" DropOnUninstall="yes"
                     ContinueOnError="no" />
            </Component>
        </ComponentGroup>
    </Fragment>
</Wix>

I had the instance name by taping this query in the Management studio :

SELECT @@servicename

However, I get an error :

CreateDatabase: Error 0x80004005: failed to create to database: 'MyDatabase', error: unknown error
Error 26201. Error -2147467259: failed to create SQL database: MyDatabase, error detail: unknown error.
MSI (s) (FC!74) [17:43:27:786]: Product: Test -- Error 26201. Error -2147467259: failed to create SQL database: MyDatabase, error detail: unknown error.

CustomAction CreateDatabase returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 17:43:27: InstallFinalize. Return value 3.

Did I miss something?

Thanks !

1
Error 0x80004005 is 'access denied'. Verify that the account running the installation has enough right in SQL Server to create databases.Yan Sklyarenko
Hi @YanSklyarenko, thanks for your answer. I added <util:User Id='sa' Name='sa' Password='password' /> and updated sql:SqlDatabase with the user. I tried to log in management studio on localhost with the user sa. I can log in and run queries but I still have the error. Users (my local user and sa user have the sysadmin role)Bob
Any idea? I used SQL Profiler, but I didn't receive any data... I used a user with sysadmin, why the access is denied?Bob
Nope, no idea, unfortunatelyYan Sklyarenko
Thanks for trying! I'll update the post if I found something.Bob

1 Answers

0
votes

I found my problem. I'm ashamed of my error : I put a instance

Instance="MSSQLSERVER"

I did not need it. I thought it was the

SELECT @@servicename

So, I don't know when we need it... Did someone know?

Thanks Yan for your help!