Page 313 - DCAP408_WEB_PROGRAMMING
P. 313

Unit 14: Database Connectivity




          The valuelist parameter is a single value or an array of values for the fields that you want to  Notes
          populate in the new record. If the fieldlist parameter is an array, then valuelist must also be an
          array. Further, the valuelist must have the exact same number of members and be in the same
          order as the fieldlist.


                 Example: Consider these examples:
          <%
          set objRS = Server.CreateObject(“ADODB.recordset”)
          RS.open “tbluser”, conn
          ‘ Method 1
          objRS.Update “FirstName”, “Rich”

          ‘ Method 2
          objRS.Update Array(“FirstName”, “LastName”), Array(“Rich”,”Smith)
          ‘ Method 3
          myFieldList = Array(“FirstName”, “LastName”)
          myValueList = Array(“Rich”, “Smith”)
          objRRS.Update myFieldList, myValueList
          objRS.close

          set objRS = nothing
          objconn.close
          set objconn = nothing
          %>
          The above examples echo the update method’s ability to update information within recordsets
          quite similarly to the addnew method.

          14.3.3 ASP Database — Deleting Information


          Using the recordset object, there is a “delete” method to delete the current record. When using
          the delete method keep in mind that the current record is deleted and is still the current record
          in the recordset. If you attempt to retrieve values from  the record,  an error will occur. This
          deleted record will hold its place in the recordset until you move to another record.
          Program for Deleting Records from Database
          1.   <%@ Language=VBScript %>
          2.   <% Option Explicit %>
          3.   <!- - #include virtual=’/adovbs.inc”- - >

          4.   <!- - #include file=”DatabaseConnect.asp”- - >
          5.   <HTML>
          6.   <BODY>
          7.   <% Dim objRS
          8.   Set objRS = Server.CreateObject(“ADODB.Recordset)
          9.   objRRS.Open “tblUsers”,objConn, adLockOptimistic, adCmdTable %>



                                           LOVELY PROFESSIONAL UNIVERSITY                                   307
   308   309   310   311   312   313   314   315   316   317   318