InstallAware数据库回滚

发布于 2024-07-14 14:48:10 字数 86 浏览 7 评论 0原文

有谁知道如何让 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

给不了的爱 2024-07-21 14:48:10

我认为 InstallAware 无法回滚数据库事务。 我没有在他们的 MS SQL Server 命令中看到任何对 SQL Server 回滚的内在支持。 如果可能的话,您需要编写自己的回滚脚本。

如果用户在初始对话框期间取消安装,则 MSICode 中通常有一个部分具有 IF 块。 它看起来像这样

if variable WIZARD Equals CANCEL
    Terminate Installation
end

这发生在 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

if variable WIZARD Equals CANCEL
    Terminate Installation
end

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文