# How to use a button to delete the record from database table using asp

**URL:** <https://forum.kirupa.com/t/how-to-use-a-button-to-delete-the-record-from-database-table-using-asp/29756>\
**Category:** Uncategorized\
**Created:** [August 30, 2003, 11:04am UTC](https://forum.kirupa.com/t/how-to-use-a-button-to-delete-the-record-from-database-table-using-asp/29756 "2003-08-30T11:04:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SBUH](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@SBUH](https://forum.kirupa.com/u/SBUH)\
**Post date:** [August 30, 2003, 11:04am UTC](https://forum.kirupa.com/t/how-to-use-a-button-to-delete-the-record-from-database-table-using-asp/29756/1 "2003-08-30T11:04:29Z")

</div>

hello, I want to use one button to remove the relative column in the database table.

I have code in asp in the attachment. Could any one take a look at it and help me please.

Because I got the sytex error with the sub function. So how to modify this code so that when I click the button, it runs the function and delete that specific column in the table. Thanks in advance!!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 31, 2003, 1:27am UTC](https://forum.kirupa.com/t/how-to-use-a-button-to-delete-the-record-from-database-table-using-asp/29756/2 "2003-08-31T01:27:15Z")

</div>

What I do is call all records, hyperlink them to there ID field in the database. When the user clicks a button it is linked to an asp page like this:

```php

<a href = "remove_record.asp?ID=<% Response.Write(rs1("ID"))%>">Remove</a> 

```

remove\_record.asp

```php

<% @ Language = "VBScript" %>

<% Dim conn %>

<%
Set conn = server.createobject("ADODB.Connection")

Set CmdDeleteRecord = Server.CreateObject("ADODB.Recordset")

conn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("yourDB.mdb")

ID = Request.QueryString ("ID")
sql = "DELETE FROM main WHERE (ID = " & ID & ")"

CmdDeleteRecord.Open SQL, conn

%>

```
