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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:29:58+00:00 2026-05-28T23:29:58+00:00

Is it possible to extract the code section inside my code and have it

  • 0

Is it possible to extract the code section inside my code and have it run in multiple threads?

The app copies over data from a FoxPro db to our SQL server over a network (the files are quite huge so the bulk copy needs to happen in increments…

It works, but I’d like to bump up the speed a bit.

1) By either having the section I marked run in multiple threads, OR as an alternative,

2) not loop through each column in the datarow,

I went for the second option… (Updated code below)

CODE

private void BulkCopy(OleDbDataReader reader, string tableName, Table table)
    {
        if (Convert.ToBoolean(ConfigurationManager.AppSettings["CopyData"]))
        {
            Console.WriteLine(tableName + " BulkCopy Started.");
            try
            {
                DataTable tbl = new DataTable();
                foreach (Column col in table.Columns)
                {
                    tbl.Columns.Add(col.Name, ConvertDataTypeToType(col.DataType));
                }

                int batch = 1;
                int counter = 0;

                DataRow tblRow = tbl.NewRow();

                while (reader.Read())
                {
                    counter++;                  
 ////This section changed
                        object[] obj = tblRow.ItemArray;
                        reader.GetValues(obj);
                        tblRow.ItemArray = obj;
////**********
                    tbl.LoadDataRow(tblRow.ItemArray, true);

                    if (counter == BulkInsertIncrement)
                    {
                        Console.WriteLine(tableName + " :: Batch >> " + batch);
                        counter = PerformInsert(tableName, tbl, batch);
                        batch++;
                    }
                }

                if (counter > 0)
                {
                    Console.WriteLine(tableName + " :: Batch >> " + batch);
                    PerformInsert(tableName, tbl, counter);
                }

                tbl = null;
                Console.WriteLine("BulkCopy Success!");
            }
            catch (Exception)
            {
                Console.WriteLine("BulkCopy Fail!");
            }
            finally
            {
                reader.Close();
                reader.Dispose();
            }
            Console.WriteLine(tableName + " BulkCopy Ended.");
        }
    }

UPDATE
I went for the second option

I wasn’t aware that while inside the while(reader.Read()) loop that i could do the following. I’t helped to greatly increase the apps performance

while (reader.Read())
{
  object[] obj = tblRow.ItemArray;
  reader.GetValues(obj);
  tblRow.ItemArray = obj;
  tbl.LoadDataRow(tblRow.ItemArray, true);
}
  • 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-28T23:29:59+00:00Added an answer on May 28, 2026 at 11:29 pm

    This may not be the answer you’re after, but have you tried running the console application in release mode first, with just one try statement, and using indexes on the reader? It’s probably not going to increase the speed a great deal by making it multi-threaded as SQL Server will be the main bottleneck.

    Of course if you don’t care too much about data integrity (for example your IDs aren’t sequential) you could change the table locking type for inserts and spin up 3-4 threads to read from certain points in the table.

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

Sidebar

Related Questions

Is it possible to extract all of the VBA code from a Word 2007
Is it possible to extract a number from a string. For example, I have
Is it possible to extract sql statements from LINQ queries ? Say, I have
Possible Duplicate: Ruby code to extract host from URL string I found this module
is that possible to extract out all the data in second sheet from each
Is it possible to extract a single file or diff of a file from
is it possible to extract dynamic loaded text from a swf (flash application) programatically
Is it possible to extract a script from an MySQL database to create a
I discovered that it is possible to extract the hard-coded strings from a binary.
Possible Duplicate: How to extract a node attribute from XML using PHP's DOM Parser

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.