Solved

Know if Record is lock

Posted on 2004-04-29
5
145 Views
Last Modified: 2010-05-02
I want to know if a record is used by other user, if it is then i want to disabled the save command button. I do this so that the user can only see the content but cannot save it if they have done some correction. The problem is that still other user can do some changes in the database since this code cannot determine that the record is used by others.
I dont know if this is the right way to do this but my code is:

if Adostinfo.LockType = adLockPessimistic then
        cmdSave.enable=false
else
        cmdSave.enable=true
end if

txtSName.text=adostinfo.recordset!stSName
txtFname.text=adostinfo.recordset!stFname

end sub

private sub cmdSave_click()
     adostinfo.recordset!stSName=txtSname.text
     adostinfo.recordset!stFname=txtFname.text
     adostinfo.recordset.update
     adostinfo.recordset.close
end sub

0
Comment
Question by:pedong
5 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 250 total points
ID: 10949154
As best as I can discover there is no means of detecting a record's lock status via ADO.  You can implement such a system yourself by creating a parallel table to your data table and managing lock information yourself.  Here's an article that describes that approach.  It was written for Delphi but the concept translates ok.

http://www.howtodothings.com/showarticle.asp?article=210

I found another article that discusses pessimistic locking and ADO in an ASP environment.  Here too the environment is different (i.e. ASP versus pure VB) but the ADO concepts should be the same either way.

http://forums.aspfree.com/archive/t-5943

For whatever it's worth, according to Microsoft pessimistic locking only works if the you use a server side cursor.  A client side cursor uses optimistic locks even if pessimistic locking is set.  See these Microsoft articles:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;252317
http://support.microsoft.com/default.aspx?scid=kb;en-us;q189853
http://support.microsoft.com/default.aspx?scid=kb;en-us;190625&Product=ado

I don't know if this'll help but here's another Microsoft Article that deals with pessimistic locks.

http://support.microsoft.com/default.aspx?scid=kb;en-us;240317&Product=ado

And here's one that describes reading an Access LDB file.

http://support.microsoft.com/default.aspx?scid=kb;EN-US;285822
0
 
LVL 22

Expert Comment

by:DarkoLord
ID: 11977333
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:
Accept BlueDevilFan's comment as an answer

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

DarkoLord
EE Cleanup Volunteer
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

Title # Comments Views Activity
Opening Remote & Local Data Connection 2 51
SSRS expression Issue finding a string 10 65
Using "ScreenUpdating" 6 55
MsgBox 4 45
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

911 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

15 Experts available now in Live!

Get 1:1 Help Now