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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:32:38+00:00 2026-06-06T19:32:38+00:00

We have a .NET application (VB / VS2010) and are calling many stored procedures

  • 0

We have a .NET application (VB / VS2010) and are calling many stored procedures on a SQL Server 2008 for database queries. We also have quite a few update/insert/delete triggers that are executed automatically once these stored procedures modify the database tables.

There are quite often situations when a stored procedure is called and it seems to perform ok as no error is raised and the .NET app continues as usual. However if I then look under the covers and perform the stored procedure call manually via SQL Server Client I see that a trigger that’s executed right after the stored procedure fails, thus rolling back all changes.

So my question is: what’s the best way to detect and pass through errors in our .NET –> stored procedure –> trigger scenario to know for sure in the .NET app that everything succeeded or not in case of an error?

Many thanks in advance,
Steve


Update: I am at home now and away from my desk (and the code base) for the weekend, so won’t have a chance to check the very details of the stored procedures. Thanks so much for the answers given so far. I can have a look at the code again next week.

But in the meantime…

One question was about the version of MS SQL Server: it’s 2008.

From what I know out of the top of my head we are calling the stored procedures (at least those that don’t read data and “just” update, delete or insert data) in this manner:

Using connection As New SqlConnection("connectionString")
    Dim command As New SqlCommand("EXEC STORED_PROCEDUR_ENAME), connection)
    command.Connection.Open()
    command.ExecuteNonQuery()
End Using

I think the assumption behind the code above is the expectation that if something fails within the stored procedure or a related trigger, that

command.ExecuteNonQuery()

would then fail. That might be my first problem, i.e. will I have to alter this code?
One question below was if I use ExecuteDataReader, so the answer is no, at least not so far…

I’ll comment on the SQL specific questions and suggestions below.

  • 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-06T19:32:40+00:00Added an answer on June 6, 2026 at 7:32 pm

    You should check @@error after each statement, and return the error if one exists.

    Here’s a good article for you. Check out the section “Why is My Error Not Raised”. It describes a scenario that could be your problem.

    http://www.sommarskog.se/error-handling-II.html

    You might also want to try turning XACT_ABORT on, so stored procedures would fail for most errors.

    EDIT: Here’s another link that might help explain this.

    http://www.novicksoftware.com/tipsandtricks/tips-erorr-handling-in-a-stored-procedure.htm

    You can either return an error from your procedure if you check @@error and find it != 0, or you can use RAISERROR, which will definitely result in an exception in calling code.

    http://msdn.microsoft.com/en-us/library/ms178592.aspx

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

Sidebar

Related Questions

I have developed a WinForm Application with VB.Net (VS2010) having Office 2010 Professional Installed,
I have a clickonce application (VS2010, .NET 4). I have registered a file association
how can I enable database logging in my ASP.net application? I am using VS2010
I have been developing an application in VS2010 and compiling it for the .NET
I have a DataGridView in a .Net application (V4 C# VS2010) & want to
I have an ASP.NET web application I'm running with VS2010 that has session timeout
we have a Asp.Net MVC 2.0 application. In Vs2010 solution Explorer there is only
I have written an web application in VS2010 ASP.net C#, to display Crystal reports.
We have a .NET web application with 172 projects on TFS 2008 that encompass
I have an asp.net web application that I made in Visual Studio 2008. Everything

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.