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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:41:18+00:00 2026-05-28T05:41:18+00:00

I am using the FileHelpers libraries to upload a CSV file to SQL Server.

  • 0

I am using the FileHelpers libraries to upload a CSV file to SQL Server. I would like to present the user with a list of records which could not be uploaded do to errors. I am setting the ErrorMode of the SqlServerStorage class to SaveAndContinue, however the InsertRecords method still throws an exception when one of the records violates a foriegn key constraint. Is there a way to save this error and continue with the insert?

SqlServerStorage storage = new SqlServerStorage(typeof(RouteRecord),ConfigurationManager.ConnectionStrings["DBConnString"].ConnectionString);
storage.ErrorManager.ErrorMode = FileHelpers.ErrorMode.SaveAndContinue;
storage.InsertRecords((RouteRecord[])Session["successfulRecordArray"]);

Thanks.

  • 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-28T05:41:18+00:00Added an answer on May 28, 2026 at 5:41 am

    Looking at the code for FileHelpers 2.9.9, the FileHelpers error handling does not seem to have been implemented for the DatabaseStorage class which is the base class for SqlServerStorage. I think the reason is probably, that the SQL statements are handled as in batches for performance reasons, so it is not possible to catch an individual record’s error.

    It would not be too difficult to add the missing error-handling by overriding InsertRecords(Object[]), but unfortunately SqlServerStorage is sealed and some of the helper routines are internal, so you’d end up having to copy several classes into your code. (If you do this, make sure that you set ExecuteInBatch to false, so that each SQL statement gets processed individually – this will affect performance).

    Alternatively, you could implement some check for foreign key violations (e.g., by enumerating RouteRecord[]) in a separate routine which is called before the InsertRecords() call, but this would not prevent errors occurring for other reasons.

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

Sidebar

Related Questions

I am reading a huge file using FileHelpers library. I would like to change
I have a record that I write out to a CSV file using FileHelpers.
I'm using the FileHelpers 2.0 library to write a CSV file using the ClassBuilder
I'm trying to parse a file using the Filehelpers library. My file looks like
Question: I need to read a CSV file. I use the FileHelpers library to
Using Rails 3.2.0 with haml and sass: I Would like to link an external
I'm using FileHelpers for reading csv files, and all it was ok until I
I followed the link of parse CSV using F# and filehelpers . got compiler
I'm using version 2.0 of the FileHelpers library which is documented as being able
Using SQL Server 2005 Leave Table ID StartDate EndDate 001 02/03/2010 02/03/2010 002 02/03/2010

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.