Locking Records & Checking if it is locked

Results 1 to 2 of 2

Thread: Locking Records & Checking if it is locked

  1. #1
    Join Date
    Dec 1969

    Default Locking Records & Checking if it is locked

    Hi All<BR><BR>How do i check if the record is locked (im using ASP & Access)<BR><BR>below is the code, but it doesnt work (doesnt show if the record is locked)<BR><BR>Set adoCon = Server.CreateObject("ADODB.Connection")<BR>strCon = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("test.mdb")<BR><BR>adoCon.Open strCon<BR>Set adoRec2 = Server.CreateObject("ADODB.Recordset")<BR><BR>if adoRec2.LockType = "2" Then<BR> response.write("Record is locked")<BR>else<BR><BR>strSQL = "SELECT * FROM test"<BR>strSQL = strSQL & " WHERE id = " & SQLVal(Request.QueryString("id"))<BR><BR>adoRec2.L ockType = 2<BR>adoRec2.Open strSQL, adoCon<BR><BR>Please help me, if you can, this is very important as im stuck with it for days... and ive to get some solution for it<BR><BR>Thanx

  2. #2
    Join Date
    Dec 1969

    Default Well, you can't specify...

    ...that you are locking a single record in an Access DB from ASP/ADO/SQL code.<BR><BR>You *CAN* specify that you are locking the *fetched* records pessimistically or optimistically.<BR><BR>Which you *should* do using the symbolic constants adLockOptimistic or adLockPessimistic, instead of just using the number 2 as you did.<BR><BR>ANYWAY... You really don&#039;t *CARE* whether the record or the page is locked when you use pessimistic locking. All you care about is that no other user can modify the record you just opened, and pessimistic locking will ensure that. Note that if you *ask* for pessimistic locking, you will *ALWAYS* get it (unless somebody has opened the DB for exculsive use, but with ASP and ADO that shouldn&#039;t happen). You might have to WAIT until a prior user&#039;s lock is released, but you will get it.<BR><BR>You might want to read this article:<BR>http://databasedadvisor.com/doc/13043<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts