Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 26th, 2003, 10:25 AM
Authorized User
 
Join Date: Sep 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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 :-)

 
Old September 26th, 2003, 02:50 PM
Authorized User
 
Join Date: Sep 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I feel especially silly right now. I have fixed my own problem. If anyone would like to know where it was it was in this line.

Response.Write("<a href=""delete.asp?News=" & "'" & rs("NewsID") & """>")

The error was with the "'". I did not need that bit of code. I took it out and it started to work. Thanks to all of those who might have looked at it.






Similar Threads
Thread Thread Starter Forum Replies Last Post
how to EDIT,delete,add,items in my database zedekiah BOOK: Beginning ASP 3.0 2 May 15th, 2008 08:16 AM
delete a composite key record from database abhi_loveu2002 ASP.NET 2.0 Basics 0 December 18th, 2006 02:12 AM
Delete record from database using radio box gavmc Classic ASP Databases 0 January 13th, 2006 10:48 AM
Help!!! Cannot Update, Delete from Access database dreamzentrue ADO.NET 7 November 3rd, 2005 06:11 PM
delete records in database shoakat Classic ASP Databases 9 October 26th, 2004 08:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.