修改数据库记录问题

fengmin2000 2005-09-20 09:58:20
modisave.asp
<%
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("all.mdb")
exec="select * from guest where id="&request.form("id")
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,3
rs("name")=request.form("name")
rs("tel")=request.form("tel")
rs("message")=request.form("message")
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
提示:
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] 语法错误 (操作符丢失) 在查询表达式 'id=' 中。
/guest_1/modisave.asp, 第 6 行

我是菜鸟,请不要见笑
...全文
96 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
jingxiaoping 2005-09-20
  • 打赏
  • 举报
回复
在你的提交页中,并没有看到有ID的值被传送到MODISAVE.ASP的页面,所以你需要在<FORM>和</FORM>表单中加入一个隐藏控件,来将ID进行传递。
<input type="hidden" name="id" value=<%=clng(request.querystring("id"))%>>

然后在MODISAVE页面,取得ID值,将ID值转换为整型。
exec="select * from guest where id="&request.form("id")
改为
exec="select * from guest where id="&clng(request.form("id"))

然后你就可以轻松执行你的修改操作了。
fengmin2000 2005-09-20
  • 打赏
  • 举报
回复
在修改的页面我能够正确的提取记录,已经正确的显示出来了,只是在提交到这个页面的时候就出问题了。

显示页面代码

<!--#include file="conn.asp"-->
<%
exec="select * from guest where id="&request.querystring("id")
set rs=server.createobject("adodb.recordset")
rs.open exec,conn
%>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<table width="409" border="0" cellpadding="5" cellspacing="1" bgcolor="#000000">
<form name="form1" method="post" action="modisave.asp">
<tr bgcolor="#FFFFFF">
<td width="82">姓名:</td>
<td width="304"> <input name="name" type="text" value="<%=rs("name")%>">
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td>电话:</td>
<td><input name="tel" type="text" value="<%=rs("tel")%>"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td>留言内容:</td>
<td><input name="message" type="text" value="<%=rs("message")%>"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td> </td>
<td><input type="submit" name="Submit" value="提交"></td>
</tr>
</form>
<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</table>
dh20156 2005-09-20
  • 打赏
  • 举报
回复
Response.write exec
Response.end

看看是不是request.form("id")没取到值

28,405

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧