Solved

AFX_SQL_ERROR_LOCK_MODE_NOT_SUPPORTED thrown for PESSIMISTIC locking in Access

Posted on 2000-05-07
7
352 Views
Last Modified: 2008-03-06
I'm using VC++ 5.0, MFC and ODBC (to Access 2000). I'm trying to issue a CRecordset SetLockingMode( pessimistic ).  MFC is throwing AFX_SQL_ERROR_LOCK_MODE_NOT_SUPPORTED.

Opening my CRecordset with Open( CRecordset::dynaset, NULL, CRecordset::none);

How can I set pessimistic without getting this exception?
0
Comment
Question by:sniles
  • 4
  • 3
7 Comments
 
LVL 57
ID: 2786513
I'd make sure your up to date on the MDAC stuff.  2.5 is the current release.  I'd try an update on that first.  

 Be aware though that I'm suggesting this only as a first troublshooting step and don't know if it will address the problem or not.

Jim.

0
 

Author Comment

by:sniles
ID: 2786714
Thanks. I'm already running MDAC 2.5
0
 
LVL 57
ID: 2787941
Alright, I'll do a little digging and see what I come up with....
Jim.
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 57
ID: 2788185
I dug around a bit and it looks like one of two things:

1. The recordset is not updateable.

2. The ODBC driver your using does not support pessimistic locking.

  I found this note at the bottom of some C++ documentation:

"Note   Relatively few ODBC drivers currently support pessimistic locking."

  Unfortunatly, they didn't say which ones do.  Is it possible for you to switch to the DAO classes?

Jim.
0
 

Author Comment

by:sniles
ID: 2788864
The recordset is updateable.  You 2nd point could well be the reason.  Here is the code that is generating the exception (in CRecordset class):
if (nLockMode == pessimistic)
{
RETCODE nRetCode;
UDWORD dwTypes;
SWORD nResult;
AFX_SQL_SYNC(::SQLGetInfo(m_pDatabase->m_hdbc, SQL_LOCK_TYPES,
      &dwTypes, sizeof(dwTypes), &nResult));
if (!Check(nRetCode) || !(dwTypes & SQL_LCK_EXCLUSIVE))
ThrowDBException(AFX_SQL_ERROR_LOCK_MODE_NOT_SUPPORTED);
      }

.... I stepped through this, and the nRetCode is not 0, so it's the second clause that's causing the failure. This makes your #2 item listed above the likely cause: Access doesn't support pessimistic locking (although I can't find anything at Microsoft's Knowledgebase that states this).

Regarding DAO: I'm unfamiliar with DAO, and am curious about the amount of work/change to switch to it, and what other issues it raises (i.e., DBMS compatibility, installation issues). Do you know a good article that covers this topic?
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 100 total points
ID: 2789301
Access does support pessimistic locking; it's the ODBC driver your using that's at fault.

  I'll hunt around for an article on ODBC vs DAO.  As I'm quite busy at the moment and not sure what your time table is on this, you might want to hop over to Microsofts web site and search the MSKB.  I'm sure you could turn up some programming examples of DAO from C++.

  My gut hunch though is that you would not find it to difficult.  The other option of course is to find an ODBC driver for Access that supports pessimistic locking.  The MSKB may be of help there two.  You might also want to post a message in the programming sections.

Jim.
0
 

Author Comment

by:sniles
ID: 2792556
That's ok.  I only meant if you happened to know of one off the top of your head -- didn't mean to send you on a quest.  I've since found some information on DAO & ODBC that should get me launched in the right direction.

Thanks very much for your help.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now