J
Joedickenson
Guest
Hi
First of all sorry if i've got the wrong place!
What i would like to know is how do i get ASP to delete ALL content in My access database at a click of a button?
I can do it by getting rid of each field but i would like to do it all at once. Is this possible?
If this helps this is the backend of a tutorial i worked on(im a newbie!)
Hope thats enough
Joe
First of all sorry if i've got the wrong place!
What i would like to know is how do i get ASP to delete ALL content in My access database at a click of a button?
I can do it by getting rid of each field but i would like to do it all at once. Is this possible?
If this helps this is the backend of a tutorial i worked on(im a newbie!)
Code:
<%
'## Dimension Variables
Dim adoCon '## Holds the database connection object
Dim rsDeleteEntry '## Holds the recordset for the record to be deleted
Dim strSQL '## Holds the SQL query to query the database
Dim IngRecordNo '## Holds the record number to be deleted
'## Read in the record number to deleted
IngRecordNo = CLng(Request.QueryString("ID"))
'## Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'## Set an active connection to the Connection object using a DSN-Less Connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("shoutdb.mdb")
'## Set an active connection to the Connection object using DSN connection (untick to use)
'adoCon.Open "DSN=guestbook"
'## Create an ADO recordset object
Set rsDeleteEntry = Server.CreateObject("ADODB.Recordset")
'## Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT shoutbox.* FROM shoutbox WHERE postid=" & IngRecordNo
'## Set the lock type so that the record is locked by ADO when its deleted
rsDeleteEntry.LockType = 3
'## Open recordset with the SQL query
rsDeleteEntry.Open strSQL, adoCOn
'## Delete the record from the database
rsDeleteEntry.Delete
'## Reset server object
rsDeleteEntry.Close
Set rsDeleteEntry = Nothing
Set adoCOn = Nothing
'## Return to the delete select page in case another record needs deleting
Response.Redirect "delete_select.asp"
%>
Hope thats enough
Joe