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 6129649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:46:02+00:00 2026-05-23T16:46:02+00:00

I have a function in which i have called a stored procedure to create

  • 0

I have a function in which i have called a stored procedure to create a new db and restore an existing db in to that newly created db..It is working fine without transaction scope but inside a transaction scope it is giving error like

Cannot perform a backup or restore operation within a transaction.
BACKUP DATABASE is terminating abnormally.
Cannot perform a backup or restore operation within a transaction.
RESTORE DATABASE is terminating abnormally

sample code:

using (Transactions.TransactionScope scope = new Transactions.TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
{
if (flag == "Yes") 
{
SqlCommand cmddb = new SqlCommand("crt_crm_db_details", con);
cmddb.CommandType = CommandType.StoredProcedure;
cmddb.CommandTimeout = 0;
cmddb.Parameters.Add("@custname", SqlDbType.NVarChar).Value = ccode;
cmddb.Parameters.Add("@blank_dbname", SqlDbType.NVarChar).Value = _blankdbCrm;
cmddb.Parameters.Add("@blank_bakpath", SqlDbType.NVarChar).Value = bakRestorePath;
cmddb.Parameters.Add("@blank_mdfpath", SqlDbType.NVarChar).Value = mdfRestorePath;
cmddb.Parameters.Add("@blank_ldfpath", SqlDbType.NVarChar).Value = ldfRestorePath;
cmddb.Parameters.Add("@usercnt", SqlDbType.NVarChar).Value = userCountdb;
SqlParameter Typedb = new SqlParameter("@errorid", SqlDbType.NVarChar);
Typedb.Direction = ParameterDirection.Output;
Typedb.Value = null;
Typedb.Size = 50;
cmddb.Parameters.Add(Typedb);
try 
{
con.Open();
cmddb.ExecuteNonQuery();
}
catch (Exception ex) 
{
VWLogger.LogMessage("Exception in crt_crm_db_details:", TraceEventType.Critical);
VWLogger.LogMessage(ex, TraceEventType.Critical);
return ex.Message;
throw new CustomSoapException(CustomSoapException.ExceptionCode.AuthenticationException, ex.Message);
}
con.Close();
}
scope.Complete();
return "Success";
}

Any suggestion?

  • 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-23T16:46:03+00:00Added an answer on May 23, 2026 at 4:46 pm

    Well, the error is pretty clear that this isn’t going to work… "Cannot perform a backup or restore operation within a transaction." isn’t very ambiguous; options:

    • execute the tsql outside of a transaction
    • if you might already have a nested transaction, use a nil-transaction TransactionScope (i.e. TransactionScopeOption.Suppress)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure called usp_getTotalOrder which looks like Select * from Order
I have a Function called dbo.GetFoo(). I also have a unit-testing Stored Procedure called
I have a stored procedure that has a parameter called UserName and in my
I have a function which calculates distance from database records. This function is called
I have a function, which is called sometimes with regular, sometimes dynamic arrays. If
I have a Function in CFC file, which will be called from .cfm file
I have this code which is called at an onChange event of an function
Now I'm sure this is super easy, I have a function called remove_deposit which
I have a class called User with static function loginRequired(), which returns false if
I have a function in a .js file that takes information stored in localStorage

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.