ASP Database Fundamentals (Part 4) - The Update Method in More Detail
(Page 4 of 9 )
Similar to the addnew method, there are two optional parameters that can be used. These are the fieldlist and the valuelist parameters. These parameters work in the same manner as the ones used by the addnew method.
The fieldlist parameter can be a single field name, or an array of field names, or the numeric (ordinal) position of the fields in the new record. For both the single name and array of names, each name must be enclosed within a pair of double quotes.
The valuelist parameter is a single value or an array of values for the fields that you want to 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.
Consider these examples:
<%
set rs = Server.CreateObject("ADODB.recordset")
rs.open “Customers”, conn
‘ Method 1
rs.Update “FirstName”, “Rich”
‘ Method 2
rs.Update Array("FirstName", "LastName"), Array("Rich",”Smith)
‘ Method 3
myFieldList = Array("FirstName", "LastName")
myValueList = Array("Rich", "Smith")
rs.Update myFieldList, myValueList
rs.close
set rs = nothing
conn.close
set conn = nothing
%>
The above examples echo the update method’s ability to update information within recordsets quite similarly to the addnew method.
Next: But What if I Goof? >>
More ASP Articles
More By Rich Smith