[Solutions] CREATE DATABASE statement not allowed within multi-statement transaction.

Source: Internet
Author: User

CREATE DATABASE statement not allowed within multi-statement transaction.

When I first reported this mistake, I went to the mother of a search.

Others are reported errors when adding data to the SQL Server admin interface.

And I, in the ASP. NET MVC program started, when the first visit, throw the exception, so other people's solution is not suitable for me.

Later, after a toss-up, accidentally happened to solve the problem.

Later, we tried to reproduce the problem in order to confirm the solution.

The general reason is that there is already an instance connected to your database, and when the ASP. NET MVC program starts, it also goes (in the form of a database file) to connect.

This is mainly because the database connection string is written like this: Server= (LocalDB) \mssqllocaldb; attachdbfilename=| Datadirectory|\mydatabase.mdf; Trusted_connection=true;

And my visual Studio 2015 SQL Server Object Explorer is just connected to this localdb instance, so ... Throw an exception ...

This exception usually occurs when connecting to an offline database file and LocalDB, and be careful not to connect again if an instance is already connected.

[Solutions] CREATE DATABASE statement not allowed within multi-statement transaction.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.