Delete from database problem
You will have to pardon me as I am rusty in my coding and some of it might look sloppy. But I can not delete from my database using a link. I'm getting a Microsoft JET Database Engine (0x80040E14)
Syntax error in string in query expression 'NewsID='4'.
/delete.asp, line 17 error. Line 17 is where it opens the link I want to delete. I will include both the "news" page and the delete page for better assistance.
"news.asp"
<html>
<body bgcolor="black" text="red">
<p><center>For officers that would like to submit news, please <a href="http://ddempsey.brinkster.net/HOM/login.asp">login</a></center>
<center>Officers can add other officers by clicking <a href="http://ddempsey.brinkster.net/HOM/login2.asp">here</a></center></p>
<%
Dim adoCon
Dim rs
Dim strSQL
set adoCon=Server.CreateObject("ADODB.Connection")
adoCon.Provider="Microsoft.Jet.OLEDB.4.0"
adoCon.Open "C:\inetpub\wwwroot\HOM\HOM.mdb"
set rs = Server.CreateObject("ADODB.recordset")
strSQL="SELECT News.* FROM News ORDER BY Date DESC;"
rs.Open strSQL, adoCon
%>
<%do until rs.EOF%>
<%for x=0 to 1 %>
<%Response.Write(rs.fields (x).value)%><br>
<%next
Response.Write("<a href=""delete.asp?News=" & "'" & rs("NewsID") & """>")
Response.Write("Delete")
Response.Write("</a><br><br>")
rs.MoveNext%>
<%loop
rs.close
adoCon.close
%>
</table></body>
</html>
----------------------------------------------
"delete.asp"
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim adoCon
Dim rsDeleteEntry
Dim strSQL
Dim lngRecordNo
lngRecordNo = Request.QueryString("News")
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Provider="Microsoft.Jet.OLEDB.4.0"
adoCon.Open "C:\inetpub\wwwroot\HOM\HOM.mdb"
Set rsDeleteEntry = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT News.* FROM News WHERE NewsID=" & lngRecordNo
rsDeleteEntry.LockType = 3
rsDeleteEntry.Open strSQL, adoCon
rsDeleteEntry.Delete
rsDeleteEntry.Close
Set rsDeleteEntry = Nothing
Set adoCon = Nothing
Response.Redirect "News.asp"
%>
----------------------------------
These are running in frames but even if I try to do it without the frames I get the same error. I have yet to figure out how to setup ASP to run frameless but to look like it has frames :-)
|