This article is a mirror article of machine translation, please click here to jump to the original article.

View: 22937|Reply: 1

[Source] The CREATE DATABASE statement is not allowed within a multi-statement transaction

[Copy link]
Posted on 4/9/2017 4:07:07 PM | | |

C# Prompts Error When Dynamically Creating SQL Databases: DROP DATABASE statements are not allowed in multi-statement transactions
If you get this error in SQL Query Analyzer, you can try the following solutions:
Open the "Query Analyzer" and then don't open any databases, so that it will not enter the processing scope of the database and will not prompt the above error. Entering a database is equivalent to applying the statement "use ***".
When the error occurs when creating dynamically in .NET, first check whether the transaction was used when executing the create database statement, the following SQL statement is not allowed to appear in the transaction:
ALTER DATABASE modifies the database
BACKUP LOG Backup logs
CREATE DATABASE to create a database
DISK INIT creates a database or transaction log device
DROP DATABASE deletes the database
DUMP TRANSACTION Dump the transaction log
LOAD DATABASE Mount a backup copy of the database
LOAD TRANSACTION Load Transaction Log backup copy
RECONFIGURE updates the current configuration (column config_value in the sp_configure result set) value of the configuration options that use the sp_configure system stored procedure change.
RESTORE DATABASE Restore a database backup made using the BACKUP command
RESTORE LOG Restore log backups made using the BACKUP command
UPDATE STATISTICS Updates information for one or more statistical groups (collections) with key value distributions in a specified table or index view




Previous:mvc Controller Autofac attribute injected into the controller
Next:Use of TransactionScope in C#
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com