Deleting records using the recordset object
- We begin with CustManage_1.asp open in the source editor. The first step is to add a Button DTC to the page.
For the purpose of this simulation, you only need to click the Button in the list on the left side of the screen and we'll drag the button into the page for you.
- The button is now in the page just below the Insert button. Now it is time set the button's properties. You do this by right-clicking the button.
- The menu is displayed, select properties.
- The Button Properties dialog is now displayed. There are only two properties that need to be set: Name to give the button a unique identifier, and Caption to set the text to be displayed on the button. Enter DeleteBtn for the name, and Delete for the caption. Then click OK.
- Now it's time to add the desired functionality to the button. To do so, you need to open the Script Outline window. This is done from the View item on the drop-down menu.
- On the View menu, move the mouse pointer over Other Windows. However, for the purpose of this simulation, you will need to click Other Windows.
- The Script Outline is now open. Now add code to the Delete button's onclick event handler just like you did in the previous two lessons. Begin by expanding the Delete button contents do gain access to its onclick event.
- Now double-click on the Delete button's onclick event.
- Now add the code in the
DeleteBtn_onclick code block. Enter
CustRecords.deleteRecord on the line between
Then right-click the source editor to view the page in the browser.
- Now select View in Browser.
- A record is displayed in the page. Test the Delete button by clicking it.
- The record was deleted and the next record is now displayed in the page. This is the end of the simulation.