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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:46:47+00:00 2026-06-12T03:46:47+00:00

I am batch adding a bunch of records from an internal system to our

  • 0

I am batch adding a bunch of records from an internal system to our web database server (eBilling type data). I have a problem where if there is a data error (seperate issue), every add after that errors out.

        foreach (InvoiceHeader invoiceHeader in invoiceHeaders)
        {
            rrn++;
            db.AddToInvoiceHeaders(invoiceHeader);
            if (rrn >= RECORDS_AT_A_TIME)
            {
                try
                {
                    db.SaveChanges();
                    rrn = 0;
                }
                catch (Exception e)
                {
                    string errorText = "Error in blah blah blah \n\n";
                    errorText += "Error: " + e.ToString();
                    Log.Error(errorText);
                    // Delete out bad record or entire set of records here.
                }
            }
        }

So the first 500 may go good, then I might get an invalid date. Nothing else gets added to the server and the logs get slammed with errors and crashes.

How can I either clear out the one record in error OR just clear out that batch of records? So it can finish properly and we can go back and fix the errors thus adding back the missing data.

Update: I want to be able to just log the error, remove the problem record(s) and move on. In this case it happens to be a date issue, I am not looking for solving this one instance, but all future unknown issues. How do I do the // Delete out bad record or entire set of records here.?

  • 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-12T03:46:49+00:00Added an answer on June 12, 2026 at 3:46 am

    This is probably a less than ideal solution, but what seems to work for what I need to move on.

            foreach (InvoiceHeader invoiceHeader in invoiceHeaders)
            {
                rrn++;
                if (rrn >= RECORDS_AT_A_TIME)
                {
                    try
                    {
                        db.SaveChanges();
                        rrn = 0;
                    }
                    catch (Exception e)
                    {
                        string errorText = "Error in blah blah\n\n";
                        errorText += "Error: " + e.ToString();
                        Log.Error(errorText);
                // Throw out all of these records so we can move on.
                // Probably not the best solution, but it works.
                        db.Dispose();
                        db = new db_Entities();
                    }
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an automated batch process that uses sqlcmd to pull data from a
how do i go about adding ftp users to an apache web server? i
The situation: I have a mvc.net web page which, when called, runs a batch
Since batch doesn't really have ints, I have to work around it with set
Is batch insertion of records possible in cakephp ? Kindly reply me if possible
I have a batch of reports that are set up to print very nicely
say I have input data like so: firstName | lastName | Country Bob |
How do I set the maximal jvm-memory without adding an extra batch-script to my
I have a batch file with some commands that I need to run with
I have a method that runs executes a batch file. This worked until I

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.