Solved

ADO Recordset Lock Type in C++

Posted on 2001-06-24
14
571 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
[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
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
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!

 

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

Technology Partners: 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

Title # Comments Views Activity
Task manager indicates my c++ program memory consumption is growing? 12 140
Dialogbox API leak? 18 109
How can i compile this github project?? 2 99
Gaming Software 1 30
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
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.

730 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