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

The Archive Base Latest Questions

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

So, I have a huge query that I need to run on an Access

  • 0

So, I have a huge query that I need to run on an Access DB. I am attempting to use a for loop to break it down because I can’t run the query all at once (it has an IN with 50k values). The reader is causing all kinds of problems hanging and such. Most times when I break up the for loop into 50-10000 values the reader will read 400 (exactly 400) values and then hang for about 3 minutes then do another hundred or so, hang, ad infinium. If I do over 10k values per query it gets to 2696 and then hangs, does another 1k or so after hanging, on and on. I have never really worked with odbc, sql or any type of database for that matter, so it must be something stupid, or is this expected? Maybe there’s a better way to do something like this? Here’s my code that is looped:

//connect to mdb
OdbcConnection mdbConn = new OdbcConnection();
mdbConn.ConnectionString = @"Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\PINAL_IMAGES.mdb;";
mdbConn.Open();

OdbcCommand mdbCmd = mdbConn.CreateCommand();
mdbCmd.CommandText = @"SELECT RAW_NAME,B FROM 026_006_886 WHERE (B='CM1' OR B='CM2') AND MERGEDNAME IN" + imageChunk;
OdbcDataReader mdbReader = mdbCmd.ExecuteReader();

while (mdbReader.Read())
{
  sw.WriteLine(@"for /R %%j in (" + mdbReader[0] + @") do move %%~nj.tif .\" + mdbReader[1] + @"\done");
  linesRead++;
  Console.WriteLine(linesRead);
}
mdbConn.Close();

Here’s how I populate the imageChunk variable for the IN by reading 5000 lines with a value line from a text file using a StreamReader:

                string imageChunk = "(";
                for (int j = 0; j < 5000; j++)
                {
                    string image;
                    if ((image = sr.ReadLine()) != null)
                    {
                        imageChunk += @"'" + sr.ReadLine() + @"',";
                    }
                    else
                    {
                        break;
                    }
                }
                imageChunk = imageChunk.Substring(0, imageChunk.Length - 1);
                imageChunk += ")";
  • 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-28T15:18:22+00:00Added an answer on May 28, 2026 at 3:18 pm

    Ended up using a data adapter… Was slow but provided constant feedback instead of freezing up. Never really got a good answer why, but got some advice on smarter ways to perform a large query.

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

Sidebar

Related Questions

I have a huge query that is being made dynamically, but I want the
I have a rather huge query that is needed in several stored procedures, and
i have a huge sql query that is attached to the rowsource of a
In my web application, I have a dynamic query that returns huge data to
I have inherited a Access database that has a query that SELECTs over 50
I have a trip that has many residencies. I need a single query that
I have a view with a huge paginated list of records that need filtering.
I have two processes one will query other for data.There will be huge amount
I have a database containing a single huge table. At the moment a query
I have huge 3D arrays of numbers in my .NET application. I need to

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.