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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:46:08+00:00 2026-05-27T18:46:08+00:00

The problem: I’m seeing a combination of E_FAIL and database corruption on each of

  • 0

The problem:
I’m seeing a combination of E_FAIL and database corruption on each of two threads that each have their own connection open to a jet 4.0 mdb.

Scenario:
I have an application where:

Thread 1 is the main thread. It has an ADO Connection open to an Jet 4.0 mdb using the provider “Microsoft.Jet.OLEDB.4.0”. It is responsible for inserting data into one of two tables located in the mdb, via

hr = pADOConn->Execute("INSERT INTO ...", NULL, adCmdText|adExecuteNoRecords, NULL);
// occasionally returns E_FAIL

Thread 2 is a child of thread 1. It also has an ADO Connection open with the exact same connection string. It is responsible for iterating through records already present in each of the two tables, “pumping” each row up to a server, and then deleting the row out of the table. This is accomplished via (abbreviated to relevant parts only):

countSQL = "select count(*) from TABLE";
iRecCount = pADORstTable->Open(countSQL, pADOConn2, adOpenKeyset, adLockOptimistic, adCmdText);

for (iRecCtr = 0; iRecCtr < iRecCount; iRecCtr++)
{
   // provides the capability to skip records
   strSQL = "SELECT TOP 1 * FROM (SELECT TOP " + iSkipRecords + 
            " * FROM TABLE ORDER BY PriKey DESC)";

   pADORst->Open(strSQL, pADOConn2, adOpenKeyset, adLockOptimistic, adCmdText);
   pADORst->get_EOF(&vbEOF);
   if (vbEOF)
      break;
   RstPriKey = GetFieldValueForPriKey(pADORst);
   pADORst->Close();
   pADORst->Release();

   // pump record to server
   ...

   // delete record
   bstrSQL = "delete from TABLE where PriKey = " + RstPriKey;
   hr = pADOConn2->Execute(bstrSQL, NULL, adCmdText|adExecuteNoRecords, NULL);
   // occasionally returns E_FAIL
}

Workarounds:

  • This was originally coded to use a single connection, which the child
    thread was passed a pointer to. We’ve since split it into two separate connections.
  • The code originally created an ado recordset to perform the insert, and used the underlying ADO recordset to perform the pADORst->Delete(). Both have since been changed to use Conn->Execute(…)
  • Our next thought is to move onto implementing a critical section, and pass that between the threads. This seems drastic, since it seems that ADO should be able to handle requests coming in from multiple connections.
  • I’m familiar with Jet 4.0’s page level locking size of 4k, and I wonder if we’re hitting that, and need to switch to record level locking.
  • I’ll entertain anyone else’s thoughts, drastic as they may be…

Edit 1:

Just tried wrapping both ->Execute()’s in a critical section; still setting E_FAIL occasionally from the DELETE FROM.

Edit 2:
Also tried closing the recordset immediately after retrieving primary key value (code updated to reflect changes)

  • 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-27T18:46:09+00:00Added an answer on May 27, 2026 at 6:46 pm

    Is there a more descriptive error message you are receiving? My guess is that is is a concurrency violation. You may try closing and releasing “pADORstTable” since both recordsets are operating on the same table. I would also close and release “pADORst” after EOF.

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

Sidebar

Related Questions

Problem: I have two spreadsheets that each serve different purposes but contain one particular
Problem: I have an address field from an Access database which has been converted
Problem: We have a web app that calls some web services asynchronously (from the
Problem: I have 2 classes, DB class and a User class, that will work
Problem is like this: I have two winapi application's. There is only one way
Problem background: I have a Qt/QML Symbian application targeting Qt 4.7.4, that requires a
Problem is that application closes without any error, VS stays opened. I have multiple
Problem: I'm making a web service that allows developers to 'register' their Mongoose schemas
Problem (simplified to make things clearer): 1. there is one statically-linked static.lib that has
Problem: Ajax suggest-search on [ n ] ingredients in recipes. That is: match recipes

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.