Forum Moderators: mack

Message Too Old, No Replies

Why the 500 error?

Forgive me. I learned ASP.net not ASP

         

chris_f

10:29 am on Sep 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all,

Please forgive me. I never learned ASP (just ASP.NET). I am trying to delete a row from an access database using ASP.

My code below does delete the row, however, instead of showing the proper page it give's me an ASP 500 error (Internal Server Error).

The page before feeds in a hidden variable from a form which contains the heading. The field in the form is called 'HidHead'. You probably don't need this though as the deletion is working.

Here's my code

<%@ LANGUAGE="VBScript" %>
<%
Const AdOpenDynamic = 1
Const adCmdText = 1
Const adLockOptimistic = 3
%>
<HTML>
<HEAD>
<TITLE>DATABASE UPDATE</TITLE>
</HEAD>
<BODY>

<%
Dim OldHeading
OldHeading = request("HidHead")
Set Cnn = Server.CreateObject("ADODB.Connection")
Set CnnRS = Server.CreateObject("ADODB.Recordset")

Cnn.Open "chrisfel"
CnnRS.Open "DELETE * " & _
"FROM Table1 WHERE (((Table1.Heading)='" & OldHeading & "'));", Cnn, adOpenDynamic, adLockOptimistic, adCmdText

%>

<h1>Article Deleted!</h1>

<hr>
<a href="default.asp">Back</a>

</BODY>
</HTML>
<%
CnnRS.Close
Cnn.Close
Set CnnRS = Nothing
Set Cnn = Nothing
%>

Thanks in advanced
Chris.

I know using a recordset is a wierd way to delete but my client needs pages which are coded similar so he can understand and alter them. What a royal pain in the a..e

ukgimp

10:41 am on Sep 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does the code positioning make any difference?

The times I have done this sort of thing I did all the delete etc above the <html> then once you had closed the connection the HTML executes to give you the confirmation. You have declared a variable in the midddle of your html. Have you tried moving that?

If the record is deleting then I dont see why it would fall down.

chris_f

10:45 am on Sep 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've just now fixed it.

I've used:

<%
Conn.execute (" [delete querystring goes here] ")
%>

Thanks for the speedy response though.

Chris.