程序执行没有报错,但是数据没有写进数据库里

HTML52226777 2006-12-15 08:51:16
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="add.asp">
<label>
<input type="text" name="id" />
</label>
<label>
<input type="text" name="password" />
</label>
<label>
<input type="submit" name="Submit" value="提交" />
</label>
<label>
<input type="reset" name="Submit2" value="重置" />
</label>
</form>
</body>
</html>

下面是 add.asp文件

<!--#include file="dbpath.asp"-->
<% dim name
dim pass
name=request.from("ID")
pass=request.from("password")
savedata()
response.redirect "index.asp"
set rs=nothing
conn.close
set conn=nothing
sub savedata()
dim insertcursor
set insertcursor = server.createobject("adodb.recordset")
insertcursor.open "select * from addnews",conn,1,3
insertcursor.addnew
insertcurrsor("username")=name
insertcurrsor("password")=pass
insertcurrsor.update
insertcurrsor.close
conn.close
set insertcursor=nothing
end sub
%>



数据库连接文件 dbpath.asp
<%
dim conn
dim connstr
on error resume next
connstr="DBQ="+server.mappath("add.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr
%>
...全文
307 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
gulingge 2006-12-17
  • 打赏
  • 举报
回复
sub savedata()
dim insertcursor
set insertcursor = server.createobject("adodb.recordset")
insertcursor.open "select * from addnews",conn,1,3
insertcursor.addnew
insertcurrsor("username")=name
insertcurrsor("password")=pass
insertcurrsor.update
insertcurrsor.close
conn.close
set insertcursor=nothing
end sub
这里的name 和 pass变量是局部的,在函数定义的时候又没有指定形参,所以这里的 用户名和密码始终是空的
HTML52226777 2006-12-17
  • 打赏
  • 举报
回复
我是在学ASP~~确实是别人的程序`~他程序里的代码我是看明白了`~
但我自己动手模仿写的时候确是错的`~现在又试了你的方法`
`还是不行`~晕死了`~
夜的眼2021 2006-12-17
  • 打赏
  • 举报
回复
相应的都改一下了

楼主应该是copy别人的吧,先看懂了再用
夜的眼2021 2006-12-17
  • 打赏
  • 举报
回复
name=trim(request("id"))
夜的眼2021 2006-12-17
  • 打赏
  • 举报
回复
name=request.from("ID")
ID-->id
from-->form相关的错误都要改,或者就写request("id")
HTML52226777 2006-12-17
  • 打赏
  • 举报
回复
没有人能解决吗`~改成request.form 去掉了 on error resume next
也把除savedata()外的那个conn.close语句去掉了~~但还是错误~~谁能重新写过这段代码?
并能保证运行`~?
peter82 2006-12-16
  • 打赏
  • 举报
回复
用response.write 一步步查看
zxmmiao 2006-12-16
  • 打赏
  • 举报
回复
Request.from()

-->

Request.form()

你的笔误

同意
deknight 2006-12-16
  • 打赏
  • 举报
回复
去掉on error resume next,显示的错误肯定是找不到XXX
因为你多了个conn.close
你的conn已经被关闭了,再关一次就出错
HTML52226777 2006-12-16
  • 打赏
  • 举报
回复
怎么没人回了`~
HTML52226777 2006-12-15
  • 打赏
  • 举报
回复
最可能的原因是:
该网站正在进行维护。
该网站有程序错误。

您可以尝试以下操作:
方法全试过`~还是不行`
hbjmdx008 2006-12-15
  • 打赏
  • 举报
回复
查看是否有写权限。
cceon 2006-12-15
  • 打赏
  • 举报
回复
删除 on error resume next
www_7di_net 2006-12-15
  • 打赏
  • 举报
回复
删除
on error resume next
就能告诉你错误了
robake 2006-12-15
  • 打赏
  • 举报
回复
楼主你把on error resume next去掉就能知道是哪出错了,应该是写权限的问题。
jxsddboy22 2006-12-15
  • 打赏
  • 举报
回复
Request.from()

-->

Request.form()

你的笔误
lhfx1985 2006-12-15
  • 打赏
  • 举报
回复
name=request.from("ID")
改为:
name=request.from("id")
应该就可以了啊!
crown520 2006-12-15
  • 打赏
  • 举报
回复
你的form 名字是form1,你就直接request.form1("id")不就好了.

28,391

社区成员

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

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