Modify records

Records can be updated in the table in two ways. The pointer pointing to the current record is updated.

Method 1

Update Method of the Recordset object saves the changes done to the record.

 Syntax:-Rsobject1.Updatewhere Rsobject1 is the name of the recordset object.

 Example:-

<%

rsstudent.Fields("FirstName") = ‘Richard’
rsstudent.Fields("Age") = 30
rsstudent.Update

%>

where rsstudent is a  variable of recordset object and Firstname and Age are  the names of fields in a table.

NOTE:- Connect to the database and open the recordset before using the above code 

Method 2

Execute method of the Connection object executes an SQL statement such as insert, update and delete.

Syntax:-

Connobject1.Execute (sql) where sql statement is a valid UPDATE statement and Connobject1 is the name of a connection object.

Example:-

Strupdate = ”Update student set age=40 where idno=101”

Connect1.execute (strupdate)

where Connect1 is a variable of connection object and strupdate is a variable name.

NOTE:- Connect to the database before using the above code  (Method 2)