7

我想在安装过程中使用 WiX 3.6 创建一个数据库。我遵循了许多教程,但我认为我做错了什么。

<?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="{A704CA9E-2833-4276-A8A8-148F1047332F}" Name="DbInstallerTest" Language="1033" Version="1.0.0.0" Manufacturer="Microsoft" UpgradeCode="2de42bd8-acc2-48bf-b3c6-09745d3a2ea4">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

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

        <Feature Id="ProductFeature" Title="DbInstallerTest" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
        </Feature>
    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
                <Directory Id="INSTALLFOLDER" Name="DbInstallerTest" />
            </Directory>
        </Directory>
    </Fragment>

    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">

            <Component Id="CMPDbInsatller"
                       Guid="{1749E57D-9CE4-42F8-924C-2A2E368B51E4}">
                <CreateFolder Directory="INSTALLFOLDER"/>
                <util:User Id="SqlUser"
                           Name="sa"
                           Password="Abc123@"/>
            </Component>
            <Component Id="cmp2"
                       Guid="{C3596364-61A0-4628-9153-1BA11DB4B778}">
                <CreateFolder Directory="INSTALLFOLDER"/>
                <sql:SqlDatabase Id="Id_db"
                                 Database="TestDatabase1"
                                 Server="(local)\SQLExpress"
                                 CreateOnInstall="yes"
                                 User="SqlUser"
                                 DropOnUninstall="yes">
                </sql:SqlDatabase>
            </Component>
        </ComponentGroup>
    </Fragment>
</Wix>

上面的代码给出了以下错误。

错误 -2147467259:未能创建 SQL 数据库:TestDatabase1。错误详情:未知错误。

这是日志内容,

=== Logging started: 2/18/2013  11:00:59 ===
Action 11:00:59: INSTALL.
Action start 11:00:59: INSTALL.
Action 11:00:59: FindRelatedProducts. Searching for related applications
Action start 11:00:59: FindRelatedProducts.
Action ended 11:00:59: FindRelatedProducts. Return value 1.
Action 11:00:59: LaunchConditions. Evaluating launch conditions
Action start 11:00:59: LaunchConditions.
Action ended 11:00:59: LaunchConditions. Return value 1.
Action 11:00:59: ValidateProductID.
Action start 11:00:59: ValidateProductID.
Action ended 11:00:59: ValidateProductID. Return value 1.
Action 11:00:59: CostInitialize. Computing space requirements
Action start 11:00:59: CostInitialize.
Action ended 11:00:59: CostInitialize. Return value 1.
Action 11:00:59: FileCost. Computing space requirements
Action start 11:00:59: FileCost.
Action ended 11:00:59: FileCost. Return value 1.
Action 11:00:59: CostFinalize. Computing space requirements
Action start 11:00:59: CostFinalize.
Action ended 11:00:59: CostFinalize. Return value 1.
Action 11:00:59: MigrateFeatureStates. Migrating feature states from related applications
Action start 11:00:59: MigrateFeatureStates.
Action ended 11:00:59: MigrateFeatureStates. Return value 0.
Action 11:00:59: ExecuteAction.
Action start 11:00:59: ExecuteAction.
Action start 11:01:01: INSTALL.
Action start 11:01:01: FindRelatedProducts.
Action ended 11:01:01: FindRelatedProducts. Return value 0.
Action start 11:01:01: LaunchConditions.
Action ended 11:01:01: LaunchConditions. Return value 1.
Action start 11:01:01: ValidateProductID.
Action ended 11:01:01: ValidateProductID. Return value 1.
Action start 11:01:01: CostInitialize.
Action ended 11:01:01: CostInitialize. Return value 1.
Action start 11:01:01: FileCost.
Action ended 11:01:01: FileCost. Return value 1.
Action start 11:01:01: CostFinalize.
Action ended 11:01:01: CostFinalize. Return value 1.
Action start 11:01:01: MigrateFeatureStates.
Action ended 11:01:01: MigrateFeatureStates. Return value 0.
Action start 11:01:01: InstallValidate.
Action ended 11:01:01: InstallValidate. Return value 1.
Action start 11:01:01: RemoveExistingProducts.
Action ended 11:01:01: RemoveExistingProducts. Return value 1.
Action start 11:01:01: InstallInitialize.
Action ended 11:01:01: InstallInitialize. Return value 1.
Action start 11:01:01: ProcessComponents.
Action ended 11:01:01: ProcessComponents. Return value 1.
Action start 11:01:01: UnpublishFeatures.
Action ended 11:01:01: UnpublishFeatures. Return value 1.
Action start 11:01:01: UninstallSqlData.
Action ended 11:01:02: UninstallSqlData. Return value 1.
Action start 11:01:02: RemoveFiles.
Action ended 11:01:02: RemoveFiles. Return value 0.
Action start 11:01:02: RemoveFolders.
Action ended 11:01:02: RemoveFolders. Return value 1.
Action start 11:01:02: CreateFolders.
Action ended 11:01:02: CreateFolders. Return value 1.
Action start 11:01:02: ConfigureUsers.
Action start 11:01:02: CreateUserRollback.
Action ended 11:01:02: CreateUserRollback. Return value 1.
Action start 11:01:02: CreateUser.
Action ended 11:01:02: CreateUser. Return value 1.
Action ended 11:01:02: ConfigureUsers. Return value 1.
Action start 11:01:02: InstallFiles.
Action ended 11:01:02: InstallFiles. Return value 1.
Action start 11:01:02: InstallSqlData.
Action start 11:01:19: CreateDatabase.
Action ended 11:01:19: CreateDatabase. Return value 1.
Action ended 11:01:19: InstallSqlData. Return value 1.
Action start 11:01:19: RegisterUser.
Action ended 11:01:19: RegisterUser. Return value 1.
Action start 11:01:19: RegisterProduct.
Action ended 11:01:19: RegisterProduct. Return value 1.
Action start 11:01:19: PublishFeatures.
Action ended 11:01:19: PublishFeatures. Return value 1.
Action start 11:01:19: PublishProduct.
Action ended 11:01:19: PublishProduct. Return value 1.
Action start 11:01:19: InstallFinalize.
CreateDatabase:  Error 0x80004005: failed to create to database: 'TestDatabase1', error:

unknown error
Error 26201. Error -2147467259: failed to create SQL database: TestDatabase1, error detail:

unknown error.
MSI (s) (94!44) [11:01:47:973]: Product: DbInstallerTest -- Error 26201. Error -2147467259:

failed to create SQL database: TestDatabase1, 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 11:01:47: InstallFinalize. Return value 3.
Action ended 11:01:48: INSTALL. Return value 3.
Action ended 11:01:48: ExecuteAction. Return value 3.
Action ended 11:01:48: INSTALL. Return value 3.
=== Logging stopped: 2/18/2013  11:01:48 ===
MSI (c) (C0:94) [11:01:48:208]: Product: DbInstallerTest -- Installation failed.

MSI (c) (C0:94) [11:01:48:209]: Windows Installer installed the product. Product Name:

DbInstallerTest. Product Version: 1.0.0.0. Product Language: 1033. Manufacturer: Microsoft.

Installation success or error status: 1603.

我在这里做错了什么?

4

4 回答 4

10

我们追了这个错误一周,最后通过进入 SQL Server 配置管理器 → SQL Server 网络配置 → MSSQLSERVER 的协议(对我们来说,默认实例)→ 启用命名管道和 TCP/IP 协议来解决它。

于 2014-03-31T18:22:09.230 回答
5

我也面临这个确切的问题,我浏览了很多论坛来解决这个问题。这是唯一对我有用的东西。在我的计算机上,SQL Server Express Edition 数据库创建失败并显示 -2147467259:未能创建 SQL 数据库:

经过几天的黑客攻击,我终于找到了解决方案!您需要做的就是在连接字符串中使用 .\sqlexpress 而不是 localhost\sqlexpress 或 127.0.0.1\sqlexpress 。我认为(我在这里可能大错特错)当您在连接字符串安装程序中使用 .\sqlexpress 时使用共享内存而不是命名管道或 TCP/IP。

来源:-2147467259的解决方法:创建SQL数据库失败

于 2014-04-24T15:43:27.223 回答
3

Err 26201 更有用。您还应该在事件日志中看到更多信息。

您的代码表明您在 SQL 实例上使用混合模式并作为 SQL 登录名进行身份验证。这表明问题很可能是您的 SQL 服务帐户没有在默认位置创建 MDF 和 LDF 文件的权限。

有关更多信息,请参阅此线程:

错误 26201。错误 -2147467259:未能创建 SQL 数据库

于 2013-02-18T14:34:54.143 回答
2

因此,我的 WiX 安装程序日志中也出现错误,但略有不同。

环境:

  • 网络服务器 = Windows 2008 R2
  • SQLServer = 带有 SQL Server 2008 R2 标准的 Windows 2008 32 位
  • 混合模式认证
  • 默认 SQL 实例

错误:

ExecuteSqlStrings:在 C:\Windows\Installer\MSI1EC7.tmp 中输入 ExecuteSqlStrings,版本 3.6.3303.0

ExecuteSqlStrings:错误 0x80004005:无法连接到数据库:'DatabaseNameBla'

错误 26203。无法连接到 SQL 数据库。(-2147467259 DatabaseNameBla) MSI (s) (20!30) [10:16:32:225]:产品:Bla 服务 -- 错误 26203。无法连接到 SQL 数据库。(-2147467259 数据库名称Bla )

研究:

  • Instance DB 在硬盘上似乎只剩下 1.6 GB。<<这可能很糟糕......
  • 我的用户是系统管理员
  • 通过 SQL 管理工具访问对同一用户没有问题。
  • SLQ 日志中没有任何内容可以帮助解决错误。只是噪音。

我的解决方案:

  • VM 有一个 D 盘,有 50 GB 可用空间
  • D 盘上的新数据库实例
  • 新实例设置为混合模式
  • 重新安装。成功!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

概括:

因此,经过数小时试图弄清楚这笔交易是什么。在此错误的情况下,它与硬盘驱动器可用空间大小有关。由于 SQL Server 处于生产状态,我们无法扩展 C 驱动器以查看是否修复了默认实例。

于 2014-04-11T15:48:57.537 回答