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

  • Home
  • SEARCH
  • 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 144015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:11:11+00:00 2026-05-11T08:11:11+00:00

I have process that needs to create a bunch of records in the database

  • 0

I have process that needs to create a bunch of records in the database and roll everything back if anything goes wrong. What I want to do is this:

Public Structure Result     Public Success as Boolean     Public Message as String End Structure  Private _Repository as IEntityRepository  Public Function SaveOrganization( _     ByVal organization As rv_o_Organization) As Result     Dim result = Result.Empty      _Repository.Connection.Open()     _Repository.Transaction = _Repository.Connection.BeginTransaction()      ''//Performs validation then saves it to the database     ''// using the current transaction     result = SaveMasterOrganization(organization.MasterOrganization)     If (Not result.Success) Then         GoTo somethingBadHappenedButNotAnException     End If      ''//Performs validation then saves it to the database     ''//using the current transaction     result = SaveOrganziation(dbOrg, organization)     If (Not result.Success) Then GoTo somethingBadHappenedButNotAnException  somethingBadHappenedButNotAnException:     _Repository.Transaction.Commit()     _Repository.Connection.Close()     Return result End Sub 

Is this an ok use of the GoTo statement, or just really bad design? Is there a more elegant solution? Hopefully this sample is able to get the point across

  • 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. 2026-05-11T08:11:12+00:00Added an answer on May 11, 2026 at 8:11 am

    If you have to ask, don’t do it.

    For your specific code, you could do it like this:

    Public Function SaveOrganization(ByVal organization As rv_o_Organization) As Result     Dim result As Result = Result.Empty      _Repository.Connection.Open()     _Repository.Transaction = _Repository.Connection.BeginTransaction()      'Performs validation then saves it to the database      'using the current transaction     result = SaveMasterOrganization(organization.MasterOrganization)      'Performs validation then saves it to the database      'using the current transaction     If result.Success Then result = SaveOrganziation(dbOrg, organization)      _Repository.Transaction.Commit()     _Repository.Connection.Close()     Return result End Sub 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a need to create a transactional process using an external API that
We have a process that needs to run every two hours. It's a process
Imagine I have a process that starts several child processes. The parent needs to
We have a site that needs to (as part of our process) generate a
I have an archiving process that basically deletes archived records after a set number
I have a process in R that creates a bunch of objects, serializes them,
I need to have a process that compiles daily data into an PDF that
I have 1 process that receives incoming connection from port 1000 in 1 linux
I challenge you :) I have a process that someone already implemented. I will
I have an ETL process that involves a stored procedure that makes heavy use

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.