Visual InterDev

Deleting Records

See Also

To delete a record in a database, you can add a control such as a Delete button to the page. The button calls the recordset's delete method to delete the current record.

You might not always be able to delete records. You need the correct settings for your recordset, adequate permissions in the database, and sufficient information to uniquely identify records. For details, see Determining When Query Results Can Be Updated.

Note   If you are writing ASP pages, you can set options that help you find errors and trace events in the scripting object model. For details, see Debugging Script Objects in ASP Pages.

To delete records in script

  1. Be sure there is a Recordset control on your page. For details, see Getting Records.

  2. In script, call the recordset script object's deleteRecord method, as in this example handlers for a button called btnDelete:
    Sub btnDelete_onclick
       rsEmployeeList.deleteRecord
    End sub
    

By default, the script illustrated above causes the page to display the record immediately following the one just deleted. If you prefer that the page display a different record, you can insert a navigation method in front of the return statement. The following example shows how you would move to the preceding record:

rsEmployeeList.deleteRecord;
rsEmployeeList.movePrevious;

For more information about writing event handlers for design-time controls, see Writing Scripts for Script Objects.