我正在创建一个网页,用户可以在其中从数据库中删除信息,并且我从数据库中收到一条错误消息,说明这一点。
Microsoft JET 数据库引擎错误“80040e14”
查询表达式“ID=”中的语法错误(缺少运算符)。
/courses/benv/2410/2013s2/3420384/assign3/delete.asp,第 50 行
我相信这是因为有一个值应该由表单传递但丢失了。但是,我看不到我在哪里失踪。
这是网页代码。第 50 行处于第 2 阶段。
<% option explicit %>
<html>
<head>
</head>
<body>
<!--#include file="dbconn.asp"-->
<!--#include file="header.asp"-->
<%
dim stage, s, sql, info
stage = request.form("stage")
if stage = "" then stage=1
'------------------------------------------------------------------
if stage = 1 then
'------------------------------------------------------------------
'--- get all the posts
' 0 1 2 3
SQL="SELECT ID, projectName, description, Created"&_
" FROM ProjectsTable"&_
" ORDER BY ID"
set info=conn.execute(SQL)
'--- create a radio-button list of the current posts
response.write "<br>" &_
"Please select the post to be deleted:" &_
"<form action=""delete.asp"" method=""post"">" &_
"<input type=""hidden"" name=""stage"" value=""2"">"
do
response.write "<input type=""radio"" name=""posttobedeleted" &_
" value="""&info(0)&""">"&info(1) &_
" "&info(2)&" "& info(3) & "<br>"
info.movenext
loop until info.eof
response.write "<input type=""submit"" value=""Delete Post!"">" &_
"</form>"
'------------------------------------------------------------------
elseif stage = 2 then
'------------------------------------------------------------------
%>
<!-- #include virtual="/courses/benv/2410/show_form_content.asp"-->
<%
dim deletePost
deletePost = Request.Form("posttobedeleted")
sql = "delete * from ProjectsTable where ID="& deletePost
conn.execute(sql)
response.write "The specified suburb has been deleted."
'------------------------------------------------------------------
end if ' stage
'------------------------------------------------------------------
response.write "<br clear=""left"">" &_
"<br>"
if stage=2 then
response.write "<i>that's all folks!</i><br>"
end if
response.write "<a href=""./"">back to main page</a>"
conn.close
%>
</body>
</html>