ADO Recordset Guide: How to Use It

The Recordset object in ADO (ActiveX Data Objects) is used to access the result set returned from a database. It offers a range of properties and methods for fetching and manipulating data in a database.

  1. Instantiate a Recordset object:
  2. Create a new Recordset object using the Server.CreateObject method.
  3. Open the link:
  4. Execute “SELECT * FROM table name” using the connection object.
  5. The connection object here can either be a pre-existing connection object or a connection object can be directly created by specifying the connection string.
  6. Manipulating data:
  7. Move to the first record in the recordset:
    rs.MoveFirst
  8. Go to the last record in the recordset:
    rs.MoveLast
  9. Move to the next record:
    rs.MoveNext
  10. Move to the previous record:
    rs.MovePrevious
  11. Retrieve the field value of the current record:
    value = rs(“field_name”)
  12. Update the field value of the current record:
    rs(“field name”) = value
  13. Add a new record:
    rs.AddNew
    rs(“field name”) = value
    rs.Update
  14. Delete the current record:
    rs.Delete
  15. Close connection.
  16. Close the rs object and set it to Nothing.

The above is the basic usage of the ADO Recordset object, which can be flexibly applied according to actual needs.

bannerAds