2011-08-02 10 views
1

SqlStringを使用してWixを使用してMyDBという名前の単純なデータベースを作成する必要があります。以下は私のコードスニペットです。行(SQL = "CREATE DATABASE MyDB")の場合、これが正しいことを知っているかもしれませんし、 'MyDB'データベースを作成しますか? UserとServer属性を正しく設定しました。ただし、これによりインストールは可能ですが、データベースは作成されません。誰が間違っているか不足していることを指摘できますか?Wix:SqlScriptを使用してデータベースを作成する方法

<sql:SqlDatabase Id='SqlDatabase' Database='master' User='SQLUser' Server='[SQLSERVER]' 
       CreateOnInstall='no' DropOnUninstall='no' ContinueOnError='yes'> 

       <sql:SqlString Id="InitialCreateDB" ExecuteOnInstall="no" ContinueOnError="yes" 
          SQL="CREATE DATABASE MyDB"/> 
      </sql:SqlDatabase> 

ありがとうございます。

+1

冗長ログは、舞台裏で何が起こっているのかを詳しく説明します。 –

+0

SQLプロファイラは、SQL Server側から詳細を提供します。 –

答えて

2

なぜデータベースを作成するためのSQLコードを含むスクリプトファイルがありませんか。

<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 Name='SQL app 1.0' Id='DB501C18-86C7-4D14-AEC0-86416A69ABDE' Language='1033' Codepage='1252' 
    Version='1.0.0' Manufacturer='ABC Ltd.'> 
      <Package Id='????????-????-????-????-????????????' Keywords='Installer' Description="SQL App 1.0 Installer" 
       Comments='Comment.' Manufacturer='ABC Ltd.' InstallerVersion='100' 
       Languages='1033' Compressed='yes' SummaryCodepage='1252' /> 
     <Media Id='1' Cabinet='Sample.cab' EmbedCab='yes' /> 
     <User Id="MySQLUser" Name="[SQLUSER]" Password="[SQLUSERPASSWORD]"></User> 
     <Directory Id='TARGETDIR' Name='SourceDir'> 
      <Directory Id='ProgramFilesFolder' Name='PFiles'> 
       <Directory Id='INSTALLDIR' Name='TestSQL'> 
         <Component Id="MySqlComponent" Guid="C50999A0-02FD-42d5-9F65-7375318DD328"> 
         <SqlDatabase Id="MySqlDatabase" Database="MyDatabase" Server="[SQLSERVER]" Instance="[SQLINSTANCE]" 
          CreateOnInstall="yes" DropOnUninstall="yes" User="MySQLUser" ContinueOnError="yes"> 
           <SqlScript Id="CreateDatabase" ExecuteOnInstall="yes" BinaryKey="CreateTablesBin"></SqlScript> 
         </SqlDatabase> 
         </Component> 
       </Directory> 
      </Directory> 
     </Directory> 
     <Binary Id="CreateTablesBin" src="CreateDatabase.sql"></Binary> 
     <Feature Id='Complete' Level='1' Description="Full" Title="Full Installation"> 
      <ComponentRef Id='MySqlComponent' /> 
     </Feature> 
    </Product> 
</Wix> 
+0

データベースを作成するために、Componentの下にあるSqlDatabase要素の入れ子に注意してください。 Database属性は[Formatted] [1]であるため、Propertiesへの参照を含めることができます。 [1]:http://msdn.microsoft.com/library/aa368609.aspx –

2

CreateOnInstallの値を "yes"に設定します。これにより、データベースのインスタンスが作成されます。

関連する問題