ASP Database Fundamentals (Part 4) - But What if I Goof?
(Page 5 of 9 )
There are times when, after making changes to the contents of a record, you may want to cancel or undo your changes. If you make changes to a record, and then move to another record in the recordset, the update method is implicitly called automatically.
Luckily, there is yet another method of the recordset object called “cancelupdate”. This method will cancel any changes you have made to the current record in the recordset. This only works, however, if you have not used the update method, or moved to another record in the recordset.
For example:
<%
ConnectionString = "DSN=MyDB”
set conn = server.createobject("adodb.connection")
conn.open ConnectionString
set rs = Server.CreateObject("ADODB.recordset")
rs.open “Customers”, conn
rs(“FirstName”) = “Rich”
if UpdateRecords = “Y” then
rs.update
else
rs.cancelupdate
end if
rs.close
set rs = nothing
conn.close
set conn = nothing
%>
Next: Updating Using the Connection Object >>
More ASP Articles
More By Rich Smith