B
B
Boris the Animal2015-12-26 22:47:14
Programming
Boris the Animal, 2015-12-26 22:47:14

DB is not created. Where is the mistake?

SQL Server Log:
Date,Source,Severity,Message
12/26/2015 23:30:44,spid57,Unknown,CREATE FILE encountered operating system error 5 (Permission denied.) while attempting to open or create the physical file 'C:\Program Files (x86)\Aleksey\Demo Application\WixTestDb.mdf'.
12/26/2015 23:30:44,spid57,Unknown,Error: 5123 Severity: 16 State: 1.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
     xmlns:sql="http://schemas.microsoft.com/wix/SqlExtension">

  <!--<?define RootFolder="..\bin\Release\DemoApplication"?>-->
  <?define RootFolder="..\bin\Debug\DemoApplication"?>
  <?define DbScriptsFolder="..\DB"?>
  <?define DemoAppExeFileName="DemoApplication.exe"?>
  <?define ServiceExeFileName="WixWindowsServiceTest.exe"?>
  <?define UtilsLibFileName="UtilsLibrary.dll"?>
  <?define DemoApplicationExeConfigFileName="DemoApplication.exe.config"?>
  <?define DemoApplicationPdbFileName="DemoApplication.pdb"?>

  <!-- Для работы с базой данных -->
  <?define DatabaseName="WixTestDb"?>
  <?define DatabaseSever="(local)"?>
  <?define DatabaseUser="sa"?>
  <?define DatabasePassword="12345"?>

  <Product Id="????????-cca8-4f6d-8eaf-dc2d6e43388e"
           Name="GeneralSetup"
           Language="1049"
           Codepage="1251"
           Version="1.0.0.0"
           Manufacturer="Aleksey"
           UpgradeCode="????????-e045-4889-a778-8fdbd5de3515">

    <Package SummaryCodepage="1251"
             Description="Программа установки Demo Application"
             Comments="Пакет установки демонстрационного приложения"
             InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

    <Media Id="1" Cabinet="demoApp1.cab" EmbedCab="yes" />

    <Property Id="FeatureStateDisabled" Value="1" />

    <!-- Атрибут Absent может принимать два значения: allow и disallow. В первом случае пользователь получит возможность
         не устанавливать набор совсем; во втором – набор будет устанавливаться в любом случае – так следует помечать необходимые для работы компоненты -->
    <!-- Наборы компонентов -->
    <Feature Id="Complete"
             Title="Demo Application"
             Description="Полная установка"
             Display="expand" Level="1"
             ConfigurableDirectory="INSTALLLOCATION"
             AllowAdvertise="no" Absent="disallow" InstallDefault="local">

      <Feature Id="RequiredComponents"
               Title="Необходимые компоненты"
               Description="Важные компоненты" Level="1" AllowAdvertise="no" Absent="disallow" InstallDefault="local">
        <ComponentRef Id="SqlDatabaseCreate"/>
      </Feature>
    </Feature>
  </Product>

  <Fragment>
    <!-- Виртуальный каталог -->
    <Directory Id="TARGETDIR" Name="SourceDir">
      <!-- Подкаталог Program Files\Aleksey\Demo Application -->
      <Directory Id="ProgramFilesFolder">
        <Directory Id="ManufacturerFolder" Name="Aleksey">
          <Directory Id="INSTALLLOCATION" Name="Demo Application" >
            <!-- Подкаталог Doc -->
            <Directory Id="HelpFilesFolder" Name="Doc" />
          </Directory>
        </Directory>
      </Directory>
      <!-- Пуск\Программы\Demo Application -->
      <Directory Id="ProgramMenuFolder">
        <Directory Id="ProgramMenuDir" Name="Demo Application" />
      </Directory>
      <!-- Рабочий стол -->
      <Directory Id="DesktopFolder" />
    </Directory>
  </Fragment>

  <Fragment>
    <Binary Id="CreateDbSqlScriptPart1"
        SourceFile="$(var.DbScriptsFolder)\CreatePart1.sql" />
    <Binary Id="CreateDbSqlScriptPart2"
        SourceFile="$(var.DbScriptsFolder)\CreatePart2.sql" />
    
    <DirectoryRef Id="INSTALLLOCATION" >

      <Component Id="SqlDatabaseCreate"
                 Guid="????????-026D-42d5-9F65-7375318D1328">
        
        <CreateFolder Directory="INSTALLLOCATION" />
        
        <util:User Id="ServiceAdministratorId" 
                   Name="$(var.DatabaseUser)" 
                   Password="$(var.DatabasePassword)" 
                   CreateUser="no" 
                   FailIfExists="no"/>

        <sql:SqlDatabase Id="MainDatabase"
                         Database="$(var.DatabaseName)"
                         Server="$(var.DatabaseSever)"
                         User="ServiceAdministratorId"
                         CreateOnInstall="yes"
                         CreateOnUninstall="no"
                         DropOnUninstall="no">

          <sql:SqlFileSpec Id="dbFileSpecification"
                           Name="$(var.DatabaseName)"
                           Filename="[INSTALLLOCATION]\$(var.DatabaseName).mdf"
                           GrowthSize="10"/>

          <sql:SqlLogFileSpec Id="SqlLogFile"
                              Filename="[INSTALLLOCATION]\$(var.DatabaseName).ldf"
                              Name="$(var.DatabaseName)Log" />

          <sql:SqlScript Id="CreateDbSqlScript1"
                         Sequence="1"
                         ContinueOnError="no"
                         ExecuteOnReinstall="yes"
                         ExecuteOnInstall="yes"
                         BinaryKey="CreateDbSqlScriptPart1" />
          
          <sql:SqlScript Id="CreateDbSqlScript2"
                         Sequence="2"
                         ContinueOnError="no"
                         ExecuteOnReinstall="yes"
                         ExecuteOnInstall="yes"
                         BinaryKey="CreateDbSqlScriptPart2" />

        </sql:SqlDatabase>

      </Component>
  </Fragment>

5bccc99a57ed4cefad956cb94d38b60d.jpg5b1020669db840ed8748536c0b5641bb.jpg

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexander Ananiev, 2015-12-26
@SaNNy32

Here you need to look at the database creation script and the error log

A
Alexey Lebedev, 2015-12-26
@swanrnd

Installation under an administrator who has rights.

R
Ref, 2015-12-28
@KargoZ

SQL Server Log:
Date,Source,Severity,Message
12/26/2015 23:30:44,spid57,Unknown,CREATE FILE encountered operating system error 5( Access denied .)

B
big_bo, 2015-12-29
@big_bo

to open or create the physical file 'C:\Program Files (x86)\Aleksey\Demo Application\WixTestDb.mdf'
I understand that C is your system drive. Tell me, have you tried creating on a different drive? And if it didn’t work out, then you need to look at the settings of the sql server itself

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question