How to Lock a record

Results 1 to 2 of 2

Thread: How to Lock a record

  1. #1
    Steria Guest

    Default How to Lock a record

    I&#039d like to do somthing like this VB code but written in ASP. I know it could be a little bit different but, is there any way?<BR><BR><BR><BR><BR>Function Update(Key As String, Change As String) As String<BR><BR>Dim objCnn As ADODB.Connection<BR>Dim objRs As ADODB.Recordset<BR><BR>On Error GoTo Error:<BR>Set objCnn = New ADODB.Connection<BR>objCnn.Open "DSN", "password"<BR><BR>Set objRs = New ADODB.Recordset<BR>objRs.CursorType = adOpenKeyset<BR>objRs.LockType = adLockPessimistic &#039&#060;--<BR>objRs.Open "SELECT * FROM table where KeyField = &#039" & Key & "&#039", objCnn, , , adCmdText<BR>objRs("ChangedField") = Change<BR><BR>If MsgBox("Sure?", vbYesNo) = vbYes Then<BR>objRs.Update<BR>Else<BR>objRs.CancelUpdate <BR>End If<BR>objRs.Close<BR><BR>Error:<BR>If Err.Number = -2147467259 Then<BR>Update = "Time expired. Another user is editing the record. Try again later."<BR>Else<BR>Position = InStr(1, Err.Description, "[SQL Server]") + 12<BR>Update = Mid(Err.Description, Position)<BR>End If<BR>End Function

  2. #2
    Join Date
    Dec 1969

    Default It should work but...

    the constant "adLockPessimistic" is not declared in VBScript. <BR>look for a file called on your computer. It&#039s 14kb, or I&#039d paste it in here.<BR><BR>For quick reference, here are the lock constants:<BR><BR>&#039---- LockTypeEnum Values ----<BR>Const adLockReadOnly = 1<BR>Const adLockPessimistic = 2<BR>Const adLockOptimistic = 3<BR>Const adLockBatchOptimistic = 4<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