Discussion Locked

Deleting records from Database

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
How do I delete records from an asp page using FrontPage from my Access 2000 database? I can add the records to the database from an asp page but am unable to delete them the same way. I also will need to find out how to update any records if possible for any changes.

7 replies

by md_hashim

Have you checked for relationships with other recorde before doing a delete? If the records are related then you need to un-relate the records before you are able to delete them.

by jfarmer

If you have the ID or a unique field for the record you want to delete, you can use the folowing ASP:

Sub DelRecord()
Set cmdDel = Server.CreateObject("ADODB.Command")
Set objRS = Server.CreateObject("ADODB.Recordset")
cmdDel.CommandText = "DELETE FROM tblDates WHERE DatesID = " & sDatesID
cmdDel.CommandType = 1
Set cmdDel.ActiveConnection = objDB
objRS.Open cmdDel
Response.Write("Date " & sLocDate & " deleted from database.
")
CmdDel.Close
objRS.Close
CmdDel = Nothing
objRS = Nothing
End Sub

branwen

by jfarmer

The previous answer is of course assuming you have already established a connection to your database in the objDB object.

This discussion is closed to new replies.