ASP Database Fundamentals (Part 4) - Updating Records with the Recordset Object
(Page 3 of 9 )
As with inserting records into a recordset, updating them has a particular method to facilitate this. The “update” method is used to save modifications to a record within a recordset to the recordset object, as well as to the connection object itself.
Here is an example in the simplest terms:
<%
ConnectionString = "DSN=MyDB”
Dim CurrSeq
CurrSeq = 0
set conn = server.createobject("adodb.connection")
conn.open ConnectionString
set rs = Server.CreateObject("ADODB.recordset")
rs.open “Customers”, conn
‘ Go through all records updating record sequence
do until rs.EOF
CurrSeq = CurrSeq + 1
rs(“CustomerSequence”) = CurrSeq
rs.Update
rs.MoveNext
loop
rs.close
set rs = nothing
conn.close
set conn = nothing
%>
As with the addnew method, there are additional ways to utilize the update method.
Next: The Update Method in More Detail >>
More ASP Articles
More By Rich Smith