Solved

AFX_SQL_ERROR_LOCK_MODE_NOT_SUPPORTED thrown for PESSIMISTIC locking in Access

Posted on 2000-05-07
7
355 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

828 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