Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SqlServer.Management.SMO.Server error when beginning transaction

Having an error when using SMO. This code has been working in VB.Net 4 and was just moved to C# and is now not functioning.

Microsoft.SqlServer.Management.Smo.Server server = new Microsoft.SqlServer.Management.Smo.Server(
    new Microsoft.SqlServer.Management.Common.ServerConnection(
    new System.Data.SqlClient.SqlConnection(connStr.ToString())));

server.ConnectionContext.Connect();
server.ConnectionContext.BeginTransaction(); // error here

Error is :

A transaction that was started in a MARS batch is still active at the end of the batch. The transaction is rolled back.

There are no other connections to the database other than the SMO.

The connection string is:

Data Source=MYPC\SqlServer;Initial Catalog=mytestdb;Integrated Security=True;User ID=;Password=;MultipleActiveResultSets=True

Has anyone seen this error when using SMO and knows what is causing it?

like image 390
Malcolm O'Hare Avatar asked Mar 16 '12 20:03

Malcolm O'Hare


1 Answers

Removing the MARS from the connection string fixed the problem.

like image 197
Malcolm O'Hare Avatar answered Sep 20 '22 17:09

Malcolm O'Hare