ADO Delete

ADO allows you to delete records from a database table using the Recordset object. This feature helps maintain clean and up-to-date data in your applications.

Key Topics

Deleting Records

Example

<%
    Dim conn, rs
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.Open "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=MyDatabase;User ID=myUser;Password=myPassword;"

    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.Open "Employees", conn, 1, 3

    rs.Filter = "EmployeeName='Jane Doe'"
    rs.Delete
    rs.Update

    Response.Write("Record deleted successfully.")

    rs.Close
    conn.Close
    Set rs = Nothing
    Set conn = Nothing
%>

Explanation: This example deletes the record of an employee named Jane Doe using the Filter and Delete methods of the Recordset object.

Key Takeaways

  • Use the Delete method to remove specific records from a database table.
  • The Filter property helps identify the target record for deletion.
  • Always call the Update method to finalize the deletion process.