Solved

AFX_SQL_ERROR_LOCK_MODE_NOT_SUPPORTED thrown for PESSIMISTIC locking in Access

Posted on 2000-05-07
7
343 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
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

757 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

21 Experts available now in Live!

Get 1:1 Help Now