Solved

ADO Recordset Lock Type in C++

Posted on 2001-06-24
14
553 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
Comment Utility
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
Comment Utility
hi ambience

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

thanx
0
 
LVL 22

Expert Comment

by:ambience
Comment Utility
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
 

Author Comment

by:sudhirchowdary
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:sudhirchowdary
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Answer accepted by:

ComTech
CS @ EE
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

771 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

7 Experts available now in Live!

Get 1:1 Help Now