Solved

AFX_SQL_ERROR_LOCK_MODE_NOT_SUPPORTED thrown for PESSIMISTIC locking in Access

Posted on 2000-05-07
7
362 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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.

737 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