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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:58:01+00:00 2026-06-17T15:58:01+00:00

I have Some Command Like Insert, Update, Create and so on that i want

  • 0

I have Some Command Like Insert, Update, Create and so on that i want to run them in some database in a SQL instance.
i use transaction scope for this and i want to run all of the commands on all databases even if some errors occurred.
if some error had happened i want to show all errors to user without committing the right commands.
but in transaction when it reaches the first error, it’ll be rolled back and i can’t continue running other commands.
my commands are like this :

using Trans as new TransactionScope

con.open()

for i as integer = 0 to n

Try
    com.commandtext = coms(i)
    com.executenonquery()

catch ex as exception
    errorCollection.add(ex.message) 
    continue for

end try

next

end using
  • 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-06-17T15:58:02+00:00Added an answer on June 17, 2026 at 3:58 pm

    The way transactions work is that SQL Server is actually keeping track of any errors occurring. If any error occurs in the transaction, SQL Server declares the transaction faulty and will not allow any further commends to be sent under the same transaction. Thus, even if the SQL error is handled by a try/catch block in your application, the transaction has already failed on the SQL Server and will thus fail when you send the next command.

    The only viable option would be to basically run each command in a transaction and then roll them back, whether they fail and succeed. If all succeed, you can then run them all in one big transaction and commit that. This will only work if they’re completely independent though.

    Your best option is probably to work around it, basically accepting you may only get the first error.

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

Sidebar

Related Questions

I have some existing SQL statements that I'd like to use as a custom
I have some scripts that I need to run that I want to access
I have a sql file test.sql used to run some SQL (create object /
I have some command-line ruby scripts for things like pre-processing text files before uploading
I have some doubt on wget command. Here is the thing I want to
I have this command to go to every directory and once there run some
I am looking for a database that can I run SQL statements on without
I have some triggers on various tables that use raiserror to tell the user
I would like to insert some data into an Access Database. DataTable dt =
I have an insert query for MySQL that looks like this: INSERT INTO table

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.