Friday, December 14, 2007

How to delete a record in Recordset?

How to delete a record in Recordset?

When we perform a "delete" function, we need to confirm that the LockType is not adLockReadOnly. After that, we can use the Delete method to delete record.

The ASP codes are written and described as below:

<%

Set conn = Server.CreateObject("Adodb.Connection")

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

Set rs = Server.CreateObject("Adodb.Recordset")

rs.Open "Member",conn,1,3

If Not rs.EOF Then

rs.Delete 'Delete the first record

End If

rs.Close

Set rs = Nothing

%>

No comments: