InstallAware数据库回滚
有谁知道如何让 InstallAware 在用户单击“取消”时回滚数据库? 与 InstallShield 不同,我没有看到任何方法来指定单个脚本何时运行。
Does anyone know how to make InstallAware do a rollback of a database when the user clicks 'Cancel'? Unlike InstallShield I'm not seeing any way to specify when individual scripts run.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为 InstallAware 无法回滚数据库事务。 我没有在他们的 MS SQL Server 命令中看到任何对 SQL Server 回滚的内在支持。 如果可能的话,您需要编写自己的回滚脚本。
如果用户在初始对话框期间取消安装,则 MSICode 中通常有一个部分具有 IF 块。 它看起来像这样
这发生在 Windows Installer 引擎实际执行安装之前。 如果您尚未执行数据库脚本,则无需执行任何操作。 如果您在此之前已应用数据库脚本,则需要提供回滚脚本(如果可能)并在该块中执行它,但在终止安装之前。
如果您在安装时取消安装,您将再次回滚更改。 当用户在安装过程运行时(即用户做出任何选择之后)按下取消按钮时,InstallAware 变量 SUCCESS 将被设置为 CANCEL。 您可以检查该条件并执行回滚脚本。 通常有一个代码块根据 SUCCESS 的值执行各种操作,您可以在其中添加代码。
作为安装的一部分,您始终可以将 SQL 脚本作为 InstallAware 执行的最后一个命令。 这将消除处理取消的需要。
I don't think InstallAware would be able to rollback a database transaction. I didn't see any intrinsic support for SQL Server rollbacks in their MS SQL Server command. You would need to code your own rollback script, if that is possible.
There is usually a section in the MSICode that has an IF block if the user cancels the installation during the initial dialogs. It looks something like this
This occurs before the Windows Installer engine actually performs the installation. If you have not executed your database scripts, then no action is required. If you have applied database scripts before this point, you will need to supply a rollback script (if possible) and execute it in that block, but before Terminate Installation.
If you cancel the installation while install, you'll have another shot of rolling back your changes. When the user presses the cancel button while the installation process is running (i.e. after the user has made any selections), the InstallAware variable SUCCESS will be set to CANCEL. You can check for that condition and execute your rollback script. There is usually a block of code that does various things based on the value of SUCCESS, you can add your code there.
You could always make your SQL script the last command executed by InstallAware as part of the installation. That would eliminate the need to handle the cancellation.