Solved

Know if Record is lock

Posted on 2004-04-29
5
144 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

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

706 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

19 Experts available now in Live!

Get 1:1 Help Now