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?
Removing the MARS from the connection string fixed the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With