Hi All,
I am just starting to play with ASP. I have been following the Connecting an Access database to ASP tutotial on the WebWiz site.
Its all gone well so far, the guest book works and I can add records via the form but I cant seem to get the delete_select.asp delete_entry.asp bit to work. I keep getting the Error 500 page.
Now am I missing something obvious - I have copied and pasted the code for the delete_select.asp straight off the page.
I have kept the file names the same and am useing the DSN-Less connection. Running on Windows Server 2003 Standard with SP2 and IIS.
Heres the code for delete_select.asp
<html>
<head>
<title>Delete Entry Select</title>
</head>
<body bgcolor="white" text="black">
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsGuestbook 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database
'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("guestbook.mdb")
'Create an ADO recordset object
Set rsGuestbook = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblComments.* FROM tblComments;"
'Open the recordset with the SQL query
rsGuestbook.Open strSQL, adoCon
'Loop through the recordset
Do While not rsGuestbook.EOF
'Write the HTML to display the current record in the recordset
Response.Write ("<br>")
Response.Write ("<a href=""delete_entry.asp?ID=" & rsGuestbook("ID_no") & """>")
Response.Write (rsGuestbook("Name"))
Response.Write ("</a>")
Response.Write ("<br>")
Response.Write (rsGuestbook("Comments"))
Response.Write ("<br>")
'Move to the next record in the recordset
rsGuestbook.MoveNext
Loop
'Reset server objects
rsGuestbook.Close
Set rsGuestbook = Nothing
Set adoCon = Nothing
%>
</body>
</html>
and heres delete_entry.asp
<%
'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 lngRecordNo 'Holds the record number to be deleted
'Read in the record number to be deleted
lngRecordNo = 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 "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("guestbook.mdb")
'Create an ADO recordset object
Set rsDeleteEntry = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblComments.* FROM tblComments WHERE ID_no=" & lngRecordNo
'Set the lock type so that the record is locked by ADO when it is deleted
rsDeleteEntry.LockType = 3
'Open the recordset with the SQL query
rsDeleteEntry.Open strSQL, adoCon
'Delete the record from the database
rsDeleteEntry.Delete
'Reset server objects
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"
%>
The rest of the files in the folder are
- guestbook.mdb
- guestbook_form.htm
- add_to_guestbook.asp
- guestbook.asp
Any help here would be great - cant see the problem, but then I don't really know what I'm looking for.
Thanks in advance
Matt