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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:09:05+00:00 2026-06-14T22:09:05+00:00

I’m experiencing a seemingly random System resource exceeded exception when running my code. The

  • 0

I’m experiencing a seemingly random “System resource exceeded” exception when running my code. The idea behind my program is that a third party piece of software is continuously writing data to a Microsoft Access database file (.res) – about every 30 seconds my code reads the data from this file, does some operations on it, and writes the results to our database. Unfortunately I cannot change the way the third party software writes data to files, I am stuck with Access data files.

This error occurs both on the production system running the WinForms program installed through Click-Once publishing as well as in a console test program on my development system. I get the exception even when running a query that returns a single integer and no other program or thread is touching the file which is located on my local disk.

Exception information:

System.Data.OleDb.OleDbException (0x80004005): System resource exceeded.
   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
   at System.Data.OleDb.OleDbCommand.ExecuteScalar()
...

Example code that reproduces the problem:

string connectionString = @"Provider = Microsoft.ACE.OLEDB.12.0; Data Source = C:\datafile.res";
string commandText = "SELECT MIN(Data_Point) FROM Channel_Normal_Table WHERE Test_ID = 1";

int connectionCounter = 0;            
object result;

while (true)
{                
    using (OleDbConnection connection = new OleDbConnection(connectionString))
    {
        connection.Open();
        connectionCounter++;

        using (OleDbCommand command = new OleDbCommand(commandText, connection))
        {
            result = command.ExecuteScalar();
        }

        connection.Close();
    }
}

Unfortunately the exception is not deterministic – I have seen it occur anywhere from the 4th command execution to the 6149th on the same file with the same code. It always occurs on the command.ExecuteScalar() line. If there is a resource leak in this code, please help me find it.

I have tried installing the hotfix found at http://support.microsoft.com/kb/2760394 (and made the required registry change), but it does not solve the problem. Any suggestions would be appreciated and aggressively pursued.

This is running on Windows 7, C# 4.0 (console and WinForms), 4 GB RAM

  • 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-14T22:09:06+00:00Added an answer on June 14, 2026 at 10:09 pm

    A couple of things I would try in your case:

    1. Since the user of the database is the application only, I would open the database in exclusive mode, this will help the driver get rid of the overhead of managing lock files (and should speed-up access to the db too).
    // Share Mode=12 - exclusive mode (16 for multi-user)
    string constr = @"Provider=Microsoft.ACE.OLEDB.12.0;" +
                     "Mode=12;Data Source = C:\datafile.res;user id=;password=;";
    
    1. Open a connection to the Access database when your program start, and leave it open until the application closes.
      In tight loops, lock-file issues creep up and cause all sorts of strange issues that are hard to debug.
      Just have a dummy table with a single record in the Access database, then open that table to read the record, but keep a permanent reference to that connection:
    private OleDbCommand PermanentCommand;
    
    void KeepLinkOpen() {
       if (PermanentCommand == null || 
           PermanentCommand.Connection == null || 
           PermanentCommand.Connection.State == System.Data.ConnectionState.Closed) {
    
         OleDbConnection conn = new OleDbConnection(connectionString);
         conn.Open();
         PermanentCommand = new OleDbCommand("SELECT * FROM DummyTable", conn);
         PermanentCommand.ExecuteReader(System.Data.CommandBehavior.Default);
      }    
    }
    
    void Disconnect() {
      if (PermanentCommand != null) {
          if (PermanentCommand.Connection != null) {
              PermanentCommand.Connection.Close();
          }
          PermanentCommand.Dispose();
          PermanentCommand = null;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a

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.