更新MST数据库时出错 - 请协助 [英] Error Updating MST database - please assist

查看:140
本文介绍了更新MST数据库时出错 - 请协助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Guys,



尝试通过转换(MST)文件更新MSI数据库。使用下面的代码。

[code]



WindowsInstaller.Installer inst =(WindowsInstaller.Installer)new Installer();



数据库instDb = inst.OpenDatabase(MSIFile.FullName,WindowsInstaller.MsiOpenDatabaseMode.msiOpenDatabaseModeReadOnly);



instDb.ApplyTransform( MSTpath,MsiTransformError.msiTransformErrorViewTransform);



WindowsInstaller.View view1 = instDb.OpenView(INSERT INTO`Registry`(`Registry`,`Root`,`Key` ,`Name`,`Value`,`Component_`)VALUES('+ Registry1 +','+ Root +','+ Key +','+ Name1 +','+ Value1 +','+ Component +'));





view1.Execute(null);



view1.Close();

instDb.Commit();

[/ code]





当我在包含instDb.ApplyTransform(MSTpath,MsiTransformError.ms)之前尝试MSI数据库时iTransformErrorViewTransform);



它适用于MSI,价值在MSI数据库中更新,

但我在上面的行中遇到错误代码



我错过了什么吗?请协助。

解决方案

检查您要插入的值的数据类型。

根据http://msdn.microsoft.com/en-us/library/aa371168(v=vs.85) .aspx [ ^ ],Root的类型为整数,因此它不应该在insert语句的values部分有引号。



此外,我相信所有列名都应该以安装程序SQL语法中的表名为前缀,但我不知道这是否是强制性的:



   INSERT INTO`Register`(`Registry``Registry`,`Registry``Root`,` Registry``Key`,`Registry` .Name`,`Registry` .Value`,`Registry` .Component_`)VALUES(' + Registry1 +  ', + Root +  ,' +键+  ',' + Name1 +   ',' + Value1 +   ',' +组件+  ') 


Hello Guys,

Am trying to update the MSI database via a transforms (MST) file. using below code.
[code]

WindowsInstaller.Installer inst = (WindowsInstaller.Installer)new Installer();

Database instDb = inst.OpenDatabase(MSIFile.FullName, WindowsInstaller.MsiOpenDatabaseMode.msiOpenDatabaseModeReadOnly);

instDb.ApplyTransform(MSTpath, MsiTransformError.msiTransformErrorViewTransform);

WindowsInstaller.View view1 = instDb.OpenView("INSERT INTO `Registry`(`Registry`,`Root`,`Key`,`Name`,`Value`,`Component_`) VALUES('" + Registry1 + "', '" + Root + "', '" + Key + "', '" + Name1 + "', '" + Value1 + "', '" + Component + "')");


view1.Execute(null);

view1.Close();
instDb.Commit();
[/code]


When i try for MSI database before including instDb.ApplyTransform(MSTpath, MsiTransformError.msiTransformErrorViewTransform);

it worked fine for MSI, the values got updated in the MSI database,
But i face error in the above line of code.

Am i missing something ? please assist.

解决方案

Check the datatypes of the values that you are trying to insert.
According to http://msdn.microsoft.com/en-us/library/aa371168(v=vs.85).aspx[^], Root is of type integer, so it shouldn't have quotes around it in the values part of the insert statement.

Also, I believe all column names should be prefixed with the table name in the Installer SQL Syntax, but I don't know if that's mandatory:

"INSERT INTO `Registry`(`Registry`.`Registry`,`Registry`.`Root`,`Registry`.`Key`,`Registry`.`Name`,`Registry`.`Value`,`Registry`.`Component_`) VALUES('" + Registry1 + "', " + Root + ", '" + Key + "', '" + Name1 + "', '" + Value1 + "', '" + Component + "')"


这篇关于更新MST数据库时出错 - 请协助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆