Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7504303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:31:50+00:00 2026-05-29T21:31:50+00:00

I keep on getting the following error every time i try to create a

  • 0

I keep on getting the following error every time i try to create a new transaction after i have backed up my database using SMO (Sql Server Management Objects):

New transaction is not allowed because there are other threads running in the session.

I have created a little console app that demonstrates the problem:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SqlServer.Management.Smo;
using System.Data.SqlClient;
using System.Data;

namespace TestSMO
{
    class Program
    {
        string username = "radandba";
        string password = "belmont";
        string servername = "e2idev\\e2isqlexpress";
        string databaseName = "e2i";
        string backupfilename = "c:\\e2i.bak";
        Server server;

        static void Main(string[] args)
        {
            Program prog = new Program();
            prog.server = new Server(prog.servername);
            prog.server.ConnectionContext.LoginSecure = false;
            prog.server.ConnectionContext.Password = prog.password;
            prog.server.ConnectionContext.Login = prog.username;

            try
            {
                prog.server.ConnectionContext.Connect();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
                return;
            }

            Console.WriteLine("Connected");
            //prog.SelectData();

            Backup backup = new Backup();
            backup.Action = BackupActionType.Database;
            backup.Database = prog.databaseName;
            backup.Devices.Clear();
            backup.Incremental = false;
            backup.Devices.AddDevice(prog.backupfilename, DeviceType.File);
            backup.BackupSetName = prog.databaseName + " database backup";
            backup.BackupSetDescription = prog.databaseName + " database - Full backup";
            backup.Initialize = true;
            backup.CopyOnly = true;
            backup.LogTruncation = BackupTruncateLogType.NoTruncate;
            backup.CompressionOption = BackupCompressionOptions.Default;

            backup.Complete += new Microsoft.SqlServer.Management.Common.ServerMessageEventHandler(prog.backup_Complete);
            backup.Information += new Microsoft.SqlServer.Management.Common.ServerMessageEventHandler(prog.backup_Information);
            backup.PercentComplete += new PercentCompleteEventHandler(prog.backup_PercentComplete);
            backup.SqlBackupAsync(prog.server);
        }

        void backup_PercentComplete(object sender, PercentCompleteEventArgs e)
        {
            Console.WriteLine("Backup progress: " + e.Percent);
        }

        void backup_Information(object sender, Microsoft.SqlServer.Management.Common.ServerMessageEventArgs e)
        {
            Console.WriteLine("Backup status: No:" + e.Error.Number + " Detail: " + e.Error.Message);
        }

        void backup_Complete(object sender, Microsoft.SqlServer.Management.Common.ServerMessageEventArgs e)
        {
            Console.WriteLine("Backup status: No:" + e.Error.Number + " Detail: " + e.Error.Message);

            SelectData();
        }

        public void SelectData()
        {
            SqlConnection sqlCon = server.ConnectionContext.SqlConnectionObject;

            try
            {
                if (sqlCon.State != System.Data.ConnectionState.Open)
                    sqlCon.Open();

                SqlTransaction trans = sqlCon.BeginTransaction();
                SqlDataAdapter adapter = new SqlDataAdapter("select * from version", sqlCon);
                adapter.SelectCommand.Transaction = trans;
                DataTable dt = new DataTable();
                adapter.Fill(dt);
                foreach (DataRow row in dt.Rows)
                {
                    Console.WriteLine(row[0]);
                }
                trans.Commit();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                sqlCon.Close();
            }
            Console.ReadLine();
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T21:31:51+00:00Added an answer on May 29, 2026 at 9:31 pm

    As stated by Anders UP turned out it was the NoLogTruncation was affecting it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting the following error message ERROR 1064 (42000): You have an error
I'm using Visual Studio 2008 Express edition, and keep getting the following error: Cascadedisplay.h(4)
I'm pretty new to ruby, I keep getting the following error: in gem_original_require': ./helpers/navigation.rb:28:
I keep getting the following error: * #1005 - Can't create table 'classorganizer.turma' (errno:
I keep getting the following error after I put the required files in my
I keep getting the following error when trying to parse some html using BeautifulSoup:
I keep getting the following error: You have an error in your SQL syntax;
I have a rails project and keep getting the following error when trying to
I am using jquery $.getJSON and keep getting the following error. Origin http://example.co.uk is
I keep getting the following error, I open visual studio and after a while

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.