Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: locking record


Message #1 by abel09@u... on Mon, 2 Dec 2002 14:33:25
Hi 
I don't want to allow the users to edit or update the same record. 
Therefore I have tried to lock the record, but have not had any luck.
(User has to click on the link to access record). I am using sequel 7.
Here is the code. Any help will be greatly appreciated.

Thx


<%
  Dim rsTicket
  strSQL = "SELECT * FROM OpenTickets " & _
           "WHERE TicketStatus = 'Active'" & _ 
                  " ORDER BY test ASC"        
  

  Set rsTicket = Server.CreateObject("ADODB.Recordset")
  rsTicket.Open strSQL, objConn, adOpenForwardOnly, adLockPessimistic, 
adCmdText
  If Not rsTicket.EOF Then
    Response.Write _
      "<TABLE BORDER=""1"" CELLSPACING=""3"" CELLPADDING=""3"">" & _
      "  <TR>" & _
      "    <TH>Ticket ID" 
               If Session("PersonID") <> "" Then 
                 Response.Write "<BR><FONT SIZE=""-1"">Click for 
Details</FONT>"
               End If 
           Response.Write "</TH>" & _
      "    <TH>Customer Name</TH>" & _
      "    <TH>Contact Name</TH>" & _
      "    <TH>ADSL Number</TH>" & _
      "    <TH>Reason</TH>" & _
	    "    <TH>Submitted By</TH>" & _
      "    <TH>Submission Date</TH>" & _
	  "    <TH>Attempt Number</TH>" & _
	    "    <TH>Attempt Time</TH>" & _
      "  </TR>"
	  
	   Dim objCmd, rsAttempt
    Set objCmd = Server.CreateObject("ADODB.Command")
    Set objCmd.ActiveConnection = objConn
     strSQL = "SELECT Max(AttemptNumber) AS MaxAttemptNumber, " & _
                    "Max(TimeStamp) AS LastAttemptTime FROM TRCTickets" 
    objCmd.CommandType = adCmdText
	  
	  
    Do While Not rsTicket.EOF
      Response.Write "<TR ALIGN=CENTER>"
      If Session("PersonID") <> "" Then
        Response.Write _ 
          "<TD><A HREF=""Attempt.asp?Item=" & rsTicket("TicketID") & """>" 
& _ 
          rsTicket("TicketID") & "</A></TD>"
      Else       
        Response.Write "<TD>" & rsTicket("TicketID") & "</TD>"
      End If
      Response.Write _ 
        "<TD>" & rsTicket("CustName") & "</TD>" & _ 
        "<TD>" & rsTicket("ContactName") & "</TD>" & _
		"<TD>" & rsTicket("ADSLNumber") & "</TD>" & _
		"<TD>" & rsTicket("Reason") & "</TD>" & _
		"<TD>" & rsTicket("SubmittedBy") & "</TD>" & _
		"<TD>" & rsTicket("SubmissionDate") & "</TD>" 
		

Message #2 by "Ken Schaefer" <ken@a...> on Tue, 3 Dec 2002 16:15:16 +1100
You need a "collision detection" strategy.

Your ADO lock only persists as long as the Recordset object exists, and that
disappears as soon as the page has finished processing and has been sent to
the user to look at.

Check out this thread:
http://p2p.wrox.com/view.asp?list=access_asp&id=238314

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <abel09@u...>
Subject: [asp_web_howto] locking record


: Hi
: I don't want to allow the users to edit or update the same record.
: Therefore I have tried to lock the record, but have not had any luck.
: (User has to click on the link to access record). I am using sequel 7.
: Here is the code. Any help will be greatly appreciated.
:
: Thx
:
:
: <%
:   Dim rsTicket
:   strSQL = "SELECT * FROM OpenTickets " & _
:            "WHERE TicketStatus = 'Active'" & _
:                   " ORDER BY test ASC"
:
:
:   Set rsTicket = Server.CreateObject("ADODB.Recordset")
:   rsTicket.Open strSQL, objConn, adOpenForwardOnly, adLockPessimistic,
: adCmdText
:   If Not rsTicket.EOF Then
:     Response.Write _
:       "<TABLE BORDER=""1"" CELLSPACING=""3"" CELLPADDING=""3"">" & _
:       "  <TR>" & _
:       "    <TH>Ticket ID"
:                If Session("PersonID") <> "" Then
:                  Response.Write "<BR><FONT SIZE=""-1"">Click for
: Details</FONT>"
:                End If
:            Response.Write "</TH>" & _
:       "    <TH>Customer Name</TH>" & _
:       "    <TH>Contact Name</TH>" & _
:       "    <TH>ADSL Number</TH>" & _
:       "    <TH>Reason</TH>" & _
:     "    <TH>Submitted By</TH>" & _
:       "    <TH>Submission Date</TH>" & _
:   "    <TH>Attempt Number</TH>" & _
:     "    <TH>Attempt Time</TH>" & _
:       "  </TR>"
:
:    Dim objCmd, rsAttempt
:     Set objCmd = Server.CreateObject("ADODB.Command")
:     Set objCmd.ActiveConnection = objConn
:      strSQL = "SELECT Max(AttemptNumber) AS MaxAttemptNumber, " & _
:                     "Max(TimeStamp) AS LastAttemptTime FROM TRCTickets"
:     objCmd.CommandType = adCmdText
:
:
:     Do While Not rsTicket.EOF
:       Response.Write "<TR ALIGN=CENTER>"
:       If Session("PersonID") <> "" Then
:         Response.Write _
:           "<TD><A HREF=""Attempt.asp?Item=" & rsTicket("TicketID") & """>"
: & _
:           rsTicket("TicketID") & "</A></TD>"
:       Else
:         Response.Write "<TD>" & rsTicket("TicketID") & "</TD>"
:       End If
:       Response.Write _
:         "<TD>" & rsTicket("CustName") & "</TD>" & _
:         "<TD>" & rsTicket("ContactName") & "</TD>" & _
: "<TD>" & rsTicket("ADSLNumber") & "</TD>" & _
: "<TD>" & rsTicket("Reason") & "</TD>" & _
: "<TD>" & rsTicket("SubmittedBy") & "</TD>" & _
: "<TD>" & rsTicket("SubmissionDate") & "</TD>"


  Return to Index