- 我需要创建一个数据库
- 在创建的数据库上运行 SQL 脚本
- 我需要以编程方式将一些数据输入到创建的数据库中
如果任何步骤失败,整个事务甚至数据库创建都应该回滚。 但是当我在 Create 数据库上使用事务属性时,它抛出异常
CREATE DATABASE statement not allowed within multi-statement transaction.
是否有任何方法可以实现相同的而不是删除数据库命令。(即以编程方式删除数据库)
最佳答案
恐怕你不能。
The CREATE DATABASE statement must run in autocommit mode (the default transaction management mode) and is not allowed in an explicit or implicit transaction.
关于c# - 如何在创建数据库命令期间使用事务属性(在 C# 中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16011785/