Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Know if Record is lock

Posted on 2004-04-29
5
Medium Priority
?
153 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
[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
5 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 1000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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…
Suggested Courses

618 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