简体   繁体   English

使用wix代码和C#创建二进制表

[英]create binary table using wix code and C#

I need query to create binary table using wix code and C#. 我需要查询以使用wix代码和C#创建二进制表。

eg: i am able to create 'AppSearch' table if not present in the msi using the code below 例如:如果使用下面的代码在msi中不存在,我能够创建“ AppSearch”表

Database database = new Database(tempmsiPath, DatabaseOpenMode.Direct);
string  query = "CREATE TABLE `AppSearch` (`Property` CHAR(255) NOT NULL, `Signature_`   
                 CHAR(255) NOT NULL  PRIMARY KEY `Property`)";
database.Execute(query);

but when i try 但是当我尝试

query = "CREATE TABLE `Binary` (`Name` CHAR(255) NOT NULL, `Data` Binary NOT NULL     
          PRIMARY KEY `Name`)";
database.Execute(query);                

i get the error " BadQuerySyntaxException was caught " 我收到错误“ BadQuerySyntaxException被捕获

SQL query syntax invalid or unsupported. SQL查询语法无效或不受支持。 Database: \\c:\\xx.msi. 数据库:\\ c:\\ xx.msi。 Invalid type specifier 'Binary' in SQL query CREATE TABLE Binary ( Name CHAR(255) NOT NULL, Data Binary NOT NULL PRIMARY KEY Name ). SQL查询CREATE TABLE BinaryName CHAR(255)NOT NULL, Data二进制NOT NULL PRIMARY KEY Name )中无效的类型说明符'Binary'。

The reason i need this is I need to add entries to binary table but some times msi does not have binary table in such cases i need to create the table otherwise i get error unknown table binary. 我需要这个的原因是我需要向二进制表中添加条目,但是有时在这种情况下,msi没有二进制表,因此我需要创建表,否则我将得到错误的未知表二进制。

Is there any any other way to create predefined table 'Binary' using c# code and WIX or let me know what i was missing? 还有什么其他方法可以使用C#代码和WIX创建预定义表“二进制”,或者让我知道我所缺少的东西吗?

Thanks! 谢谢!

If you use the EnsureTable Element , WiX will build an MSI with these tables even if they don't have any data. 如果使用确保表元素 ,则WiX将使用这些表构建MSI,即使它们没有任何数据也是如此。 Then you won't need any of this code. 然后,您将不需要任何此代码。

I was under the impression you used WiX to build your MSI and was missing the Binary table. 我给您的印象是您使用WiX构建您的MSI,但缺少Binary表。 If you didn't build the MSI and are trying to add the Binary table ( you would normally do this to create a transform not in the MSI itself ) then the easiest way would probably be: 如果您没有构建MSI并尝试添加Binary表(通常会这样做,而不是在MSI本身中创建一个转换),那么最简单的方法可能是:

One Time: Using ORCA: 1) Create an MSI 2) Add the Binary table to the MSI. 一次:使用ORCA:1)创建一个MSI 2)将Binary表添加到MSI。 ( Right Click, Add Table ) 3) Export the new table to an IDT file ( Right Click, Export Tables) (右键单击,添加表)3)将新表导出到IDT文件(右键单击,导出表)

The result will be a file called Binary.idt. 结果将是一个名为Binary.idt的文件。 It'll look something like this: ( whitespaces are important as it's a tab delimited file so create it yourself; don't copy and paste ) 看起来像这样:(空格很重要,因为它是制表符分隔的文件,所以请您自己创建;不要复制和粘贴)

Name    Data
s72 v0
Binary  Name

Now in DTF you can use the Import method on the Database object to import the IDT into the database as the Binary table. 现在,在DTF中,您可以使用Database对象上的Import方法将IDT作为Binary表导入到数据库中。

database.ImportTable("Binary.idt");

refer by https://docs.microsoft.com/en-us/windows/desktop/msi/sql-syntax 通过https://docs.microsoft.com/zh-CN/windows/desktop/msi/sql-syntax进行引用

SQL shoud be SQL应该是

CREATE TABLE `Binary` (`Name` CHAR(72) NOT NULL, `Data` OBJECT NOT NULL PRIMARY KEY `Name`)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM