CRecordset::SetLockingMode() function

CRecordset::SetLockingMode() function

Post by Roberto Ca » Thu, 13 Nov 2003 23:37:43


Hi at all,
i made an application in Vstudio 6.0 using CRecordset to communicate to
another computer where is the sqlserver 7.0, via ODBC.
When i save a record genric in a generic table i used (or i would use) the
function SetLockingMode(pessimistic) (after the Open and before the Edit)to
save my record. But the call to this function generates an exception and
says "Requested lock mode is not supported". I wrong in something or is
necessary a new odbc driver?
If i need a new driver that permits to me to make the SetLockMode() where i
can get it?

thanks a lot

roberto
 
 
 

CRecordset::SetLockingMode() function

Post by Ali R » Fri, 14 Nov 2003 01:03:25

I had the same problem a few years ago with VC++ 6.0, I called Microsoft,
they said that it was a screwup by one of their programmers. They gave me a
long work around, but I can't remember what it was.
Sorry I couldn't be specific, but I hope this helps in someway.

Ali R.



Edit)to
i

 
 
 

CRecordset::SetLockingMode() function

Post by Tim » Fri, 14 Nov 2003 06:56:42

Roberto,

Pessimistic locking is something to avoid since it results in the record
being locked for the duration of the Edit / Update. Since the record is
locked for the entire duration, a further round trip is needed to the server
to obtain the lock when Edit is executed. In addition, you need to be
careful about the code that occurs between Edit and Update - if you show a
message box and the user goes out to lunch, the record (page, or table)
stays locked.

The problems that are inherent with pessimistic locking may be the reasons
why this topic comes up so rarely - by far most people use optimistic
locking where the record is locked for the duration of the Update phase
only. See also TimeStamp data type.

So, my suggestion is the obvious one - use optimistic locking and use it
correctly. Your application will have better performance, SQL Server will be
better able to server a higher number of concurrent users, and overall
coding & debugging will be easier with a reduced cost of maintenance.

If you have special requirements for locking the record, then perhaps post
back and describe those requirements. Recently another OP needed to
impliment a Check Out style function - as an example. Failing that, search
MSDN for SetLockingMode.

- Tim





Edit)to
i