Solved

ADO Recordset Lock Type in C++

Posted on 2001-06-24
14
564 Views
Last Modified: 2012-05-04
hi all..

i am select one record from one table by opening a recordset using ADO (C++) as

m_pApprRecordSet->Open(sCommand,                          m_vConnection,
                 adOpenStatic,
                 adLockPessimistic,
                 adCmdText);

while this recordset is open, i want to restrict (should not allow read access also) other application to access this record (literally this record should become un-visible) untill i update that record, commit the transaction and close that recordset.

for this i am using ADO's "adLockPessimistic" as lock type while opening the recordset. but what i found is that, while my recordset is open, this record is still visible to other apps and they are able to read the values from this record...

can anyone have ideas...

(i have asked a related question about record level locking in Oracle section also)

thanx

0
Comment
Question by:sudhirchowdary
14 Comments
 
LVL 22

Expert Comment

by:ambience
ID: 6223332
I think of using BeginTrans and using the isolationlevel property to achieve the required results.

I wonder if setting iso-level to adXactIsolated could make the DBMS hold exclusive access lock on the record under-question , but i think this may help

correct me if am wrong
0
 

Author Comment

by:sudhirchowdary
ID: 6224712
hi ambience

the isolation level property is of no help for this situation...

thanx
0
 
LVL 22

Expert Comment

by:ambience
ID: 6226468
Somehow i thought that specifying the highest level of isolation level for a transaction causes the DBMS to hold exclusive lock on the records and no read or write can be done against it , this was the only way i thought of, maybe that is not applicable to you..

i'll try to find out some other ways if possible :)
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:sudhirchowdary
ID: 6228828
hi ambience
i am looking at the possibilty of using isolation preperty, but i couldn't find any detailed explanation about how it works...do you have any links where i can find more info about using that

thanks a lot for the ideas..i appreciate it

hi all
i have a question for if you are familair with ADO locks...does the adLockPessimistic is supposed to lock read access?

thanks

Sudhir
0
 

Author Comment

by:sudhirchowdary
ID: 6228830
hi ambience
i am looking at the possibilty of using isolation preperty, but i couldn't find any detailed explanation about how it works...do you have any links where i can find more info about using that

thanks a lot for the ideas..i appreciate it

hi all
i have a question for if you are familair with ADO locks...does the adLockPessimistic is supposed to lock read access?

thanks

Sudhir
0
 

Author Comment

by:sudhirchowdary
ID: 6228883
hi agian...
i guess adLockPessimistic in ADO avoids other applications from reading the record which is locked. i am trying this in C++ ( with COM) in MTS transaction...
can any one tell me if i need to assign any other properties or cursor typs etc...to use this.

Sudhir
0
 

Author Comment

by:sudhirchowdary
ID: 6229149
hi agian...
i guess adLockPessimistic in ADO avoids other applications from reading the record which is locked. i am trying this in C++ ( with COM) in MTS transaction...
can any one tell me if i need to assign any other properties or cursor typs etc...to use this.

Sudhir
0
 

Author Comment

by:sudhirchowdary
ID: 6229310
hi agian...
i guess adLockPessimistic in ADO avoids other applications from reading the record which is locked. i am trying this in C++ ( with COM) in MTS transaction...
can any one tell me if i need to assign any other properties or cursor typs etc...to use this.

Sudhir
0
 

Author Comment

by:sudhirchowdary
ID: 6229416
hi agian...
i guess adLockPessimistic in ADO avoids other applications from reading the record which is locked. i am trying this in C++ ( with COM) in MTS transaction...
can any one tell me if i need to assign any other properties or cursor typs etc...to use this.

Sudhir
0
 
LVL 22

Accepted Solution

by:
ambience earned 300 total points
ID: 6229925
Pessimistic lock doesnot let others access the data, this is an exclusive all lock.
The adLockPessimistic setting is not supported if the CursorLocation property is set to adUseClient.

A Provider may not support all lock types , i thought you tried to you adLockPessimistic and then failed to achieve the effect.

>>>
but what i found is that, while my recordset is open, this record is still visible to other apps and they are able to read the values from this record...
<<<<

Use the Supports method to determine if the Recordset supports what kind of locks..
0
 

Author Comment

by:sudhirchowdary
ID: 6229958
hi ambience,

i am using adUseClient cursor type...so i guess i need to change it to adUseServer...thanks for the comment..i will try this and get back to you..

this issue is bothering me as my deadline is nearing

thanks a lot
0
 

Author Comment

by:sudhirchowdary
ID: 6230041
hi ambience,

i am using adUseClient cursor type...so i guess i need to change it to adUseServer...thanks for the comment..i will try this and get back to you..

this issue is bothering me as my deadline is nearing

thanks a lot
0
 
LVL 11

Expert Comment

by:griessh
ID: 6820052
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to accept "ambience" comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points.
The link to the Community Support area is: http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner

0
 

Expert Comment

by:ComTech
ID: 6837749
Answer accepted by:

ComTech
CS @ EE
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

816 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

10 Experts available now in Live!

Get 1:1 Help Now