2

我试图在安装过程中使用 Windows Installer XML (WiX) 为 SQL Server 2008 R2 数据库建立数据源名称 (DSN) 以安装在 Windows 7 机器上。我在一个对话窗口中设置了两个集成的安全条件,我的问题是一个失败。Windows 身份验证 (INTEGRATEDSECURITY = “Yes”) 工作正常且没有错误。SQL Server 身份验证 (INTEGRATEDSECURITY = “No”) 在 SQL 用户名和密码上失败。至少它是这样认为的,因为 SQL Server 名称和数据库名称就像 Windows 身份验证的魅力一样。我希望有人会有一个解决方案,不需要我使用第三方扩展来使用 SQL Server 身份验证创建与数据库的正确 ODBC DSN 连接。

在失败路径上安装期间的错误为:

“配置 ODBC 数据源时出错:DB_Test,ODBC 错误 8:无效的关键字-值对。验证文件 DB_Test 是否存在并且您可以访问它。”</p>

ODBC 数据源如下:

<Component Id="DB_Test_DSN_SSPI" Guid="{******}">
  <Condition>INTEGRATEDSECURITY = "Yes"</Condition>
    <ODBCDataSource Id="DB_Test_DSN_SSPI" Name="DB_Test $(var.DisplayVersion)" DriverName="SQL Server" KeyPath="yes" Registration="machine">
      <Property Id="Server" Value="[SERVERNAME]" />
      <Property Id="Database" Value="[DATABASENAME]" />
      <Property Id="Description" Value="DB_Test" />
      <Property Id="Trusted_Connection" Value="[INTEGRATEDSECURITY]" />
    </ODBCDataSource>
</Component>
<Component Id="DB_Test_DSN_SQLAUTH" Guid="{*****}">
  <Condition>INTEGRATEDSECURITY = "No"</Condition>
    <ODBCDataSource Id="DB_Test_DSNSQLAUTH" Name="DB_Test $(var.DisplayVersion)" DriverName="SQL Server" KeyPath="yes" Registration="machine">
      <Property Id="Server" Value="[SERVERNAME]" />
      <Property Id="Database" Value="[DATABASENAME]" />
      <Property Id="Description" Value="DB_Test" />
      <Property Id="Trusted_Connection" Value="[INTEGRATEDSECURITY]" />
      <Property Id="uid" Value="[DATABASEUSER]" />
      <Property Id="pwd" Value="[DATABASEPASS]" />
    </ODBCDataSource>
</Component>

自定义对话框 UI 如下:

<Dialog Id="DialogDatabase" Width="370" Height="270" Title="$(var.ProductName) Setup">      
   <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="{\WixUI_Font_Title}Specify Database" />
   <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="Specify the location of the DB_Test" />

   <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallDirDlgBannerBitmap)" />
   <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
   <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />

   <Control Id="ServerNameLabel" Type="Text" X="32" Y="54" Width="290" Height="13" NoPrefix="yes" Text="SQL Server (Hostname\Instance,Port):" />
   <Control Id="ServerNameEdit" Type="Edit" X="32" Y="66" Width="290" Height="18" Property="SERVERNAME" />

   <Control Id="DatabaseNameLabel" Type="Text" X="32" Y="88" Width="290" Height="13" NoPrefix="yes" Text="Database name:" />
   <Control Id="DatabaseNameEdit" Type="Edit" X="32" Y="100" Width="290" Height="18" Property="DATABASENAME" />

   <Control Id="INTEGRATEDSECURITY" Type="RadioButtonGroup" X="32" Y="124" Width="290" Height="28" HasBorder="yes" Property="INTEGRATEDSECURITY" Text="Select Authentication Method">
      <RadioButtonGroup Property="INTEGRATEDSECURITY">
         <RadioButton Value="Yes" X="8" Y="12" Width="130" Height="10" Text="Windows Authentication" />
         <RadioButton Value="No" X="150" Y="12" Width="130" Height="10" Text="SQL Server Authentication" />
      </RadioButtonGroup>
   </Control>

   <Control Id="DatabaseUserLabel" Type="Text" Hidden="yes" X="32" Y="158" Width="290" Height="13" NoPrefix="yes" Text="SQL Username:">
      <Condition Action="show"><![CDATA[INTEGRATEDSECURITY = "No"]]></Condition>
      <Condition Action="hide"><![CDATA[INTEGRATEDSECURITY = "Yes"]]></Condition>
   </Control>
   <Control Id="DatabaseUserEdit" Type="Edit" Hidden="yes" X="32" Y="170" Width="290" Height="18" Property="DATABASEUSER">
      <Condition Action="show"><![CDATA[INTEGRATEDSECURITY = "No"]]></Condition>
      <Condition Action="hide"><![CDATA[INTEGRATEDSECURITY = "Yes"]]></Condition>
   </Control>

   <Control Id="DatabasePassLabel" Type="Text" Hidden="yes" X="32" Y="192" Width="290" Height="13" NoPrefix="yes" Text="SQL Password:">
      <Condition Action="show"><![CDATA[INTEGRATEDSECURITY = "No"]]></Condition>
      <Condition Action="hide"><![CDATA[INTEGRATEDSECURITY = "Yes"]]></Condition>
   </Control>
   <Control Id="DatabasePassEdit" Type="Edit" Hidden="yes" X="32" Y="204" Width="290" Height="18" Property="DATABASEPASS" Password="yes">
      <Condition Action="show"><![CDATA[INTEGRATEDSECURITY = "No"]]></Condition>
      <Condition Action="hide"><![CDATA[INTEGRATEDSECURITY = "Yes"]]></Condition>
   </Control>

   <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="Next">
      <!--<Publish Event="NewDialog" Value="VerifyReadyDlg">1</Publish>-->
   </Control>
   <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="Back">
      <!--<Publish Event="NewDialog" Value="CustomizeDlg">1</Publish>-->
   </Control>
   <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
      <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
   </Control>
</Dialog>

谢谢大家帮我解答这个问题!

4

1 回答 1

3

我有同样的错误...通过一些研究,我认为这与由于安全原因不支持 SQL 连接的 uid 和 pwd 有关。这让我认为需要通过自定义操作而不是 ODBCDataSource 来设置 ODBC 连接...

于 2012-11-26T19:17:37.137 回答