Solved

ADO Recordset Lock Type in C++

Posted on 2001-06-24
14
558 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

920 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

17 Experts available now in Live!

Get 1:1 Help Now