我是 Wix 安装程序的新手。我有一个要求,必须提供 SQL Server 登录凭据并从特定路径运行脚本。
我不明白出了什么问题。项目已成功构建并创建了 .msi。运行后我收到以下错误:
错误26204。错误-2147217900:无法执行SQL字符串,错误详细信息:'»'附近的语法不正确。,SQL键:CreateUpsizingDatabase SQL字符串:print Convert(varchar(25),GetDate(),121) + '执行文件:SqlTest.sql'
我的Sql脚本文件如下:
print Convert(varchar(25),GetDate(),121) + ' 执行文件:SqlTest.sql'
下面是我的代码:
<?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="SqlTest" Language="1033" Version="1.0.0.0" Manufacturer="BLRSCCMCAS01" UpgradeCode="0931a445-07bf-4494-b130-a1f96155021f">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="SqlTest" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<Binary Id="CreateUpsizingDatabase" SourceFile="C:\Temp\SqlTest.sql" />
<util:User Id="SQLUser" Name="[User]" Password="[Password]" />
<sql:SqlDatabase Id="SqlDatabase" Database="[MyDb]" Server="[Server]" User="SQLUser" />
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SqlTest" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="SqlComponent" Guid="15CCE46E-8EA5-42CA-80C5-AC3DB30A9716">
<sql:SqlScript Id="CreateDatabases" SqlDb="SqlDatabase" ExecuteOnInstall="yes" BinaryKey="CreateUpsizingDatabase" />
<CreateFolder/>
</Component>
</ComponentGroup>
</Fragment>
</Wix>
看起来你有一个UTF8 BOM http://unicode.org/faq/utf_bom.html(ï?¿) 在那里。尝试使用 Visual Studio 中的高级保存选项将文件另存为“Unicode(UTF8 无签名)”。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)