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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:52:59+00:00 2026-05-16T05:52:59+00:00

I’m trying to write Windows app to get data from From Fox Pro DB,

  • 0

I’m trying to write Windows app to get data from From Fox Pro DB, and inset it to Sql Server 2008 db.

I wrote code, but it works very slow. rowsCount more than 1 million
My code below:

OleDbConnection cn = new OleDbConnection(foxProConnectionString);
SqlConnection cSql = new SqlConnection(sqlServerConnectionString);
cSql.Open();

OleDbCommand ocmd = new OleDbCommand("Select * from " + table, cn);
OleDbDataAdapter sda = new OleDbDataAdapter(ocmd);
DataTable dt = new DataTable();
sda.Fill(dt);
SqlCommand mySqlcmd = new SqlCommand();
mySqlcmd.Connection = cSql;

for (int i = 0; i < dt.Rows.Count; i++)
{
   mySqlcmd.CommandText = "INSERT INTO sqlTable (column1, column2, column3) VALUES ("+dt.Rows[i][dt.Columns.IndexOf("column1")] + ",'" 
                                           + DoOper1(dt.Rows[i]dt.Columns.IndexOf("column2")]) + "','"
                                           + dt.Rows[i][dt.Columns.IndexOf("column3")] + "')";

   mySqlcmd.ExecuteNonQuery();
}

I cant use bulk copy, database columns order may be different in some source tables.
Also I get error:

The CLR has been unable to transition
from COM context 0x54afe8 to COM
context 0x54b158 for 60 seconds. The
thread that owns the destination
context/apartment is most likely
either doing a non pumping wait or
processing a very long running
operation without pumping Windows
messages. This situation generally has
a negative performance impact and may
even lead to the application becoming
non responsive or memory usage
accumulating continually over time. To
avoid this problem, all single
threaded apartment (STA) threads
should use pumping wait primitives
(such as CoWaitForMultipleHandles) and
routinely pump messages during long
running operations.

how can I solve a set of my problem?

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

    I think there are ways to get around your problems with Bulk Copy and I suggest you/we work through those rather than try to examine why a slow technology is slow. You say the reasons you can’t use Bulk Copy are because the database column order may be different in some source tables. My response to that is, why does that matter? If you are using the SqlBulkCopy object, don’t you have total control over how the columns in the source tables map to the columns in the destination tables? (Have you tried using the SqlBulkCopy object?) You also say that you can an error message about an unresponsive program. It looks like it’s related to COM. I don’t see why that would be a problem with Bulk Copy over something that takes even longer to execute. If necessary, you may have to perform Bulk Copy operations in smaller batches (perhaps completely finishing/committing batches before beginning the next?) in order for your program not to “lose control” over its execution. Does this help or provoke any further questions that may lead to an answer?

    Edit:
    Can you do something like this?

    System.Data.SqlClient.SqlBulkCopy bc = new System.Data.SqlClient.SqlBulkCopy("...");
    
    // Begin a loop to process managable-size batches of source data.
    
    using (System.Data.DataTable dtTarget = new System.Data.DataTable("sqlTable"))
    {
    
       // Populate dtTarget with the data as it should appear
       // on the SQL Server side.
       // If the mapping is simple, you may be able to use
       // bc.ColumnMappings instead of manually re-mapping.
    
       bc.DestinationTableName = "sqlTable";
       bc.WriteToServer(dtTarget);
    }
    
    // End loop.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from

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.