新手问题 100(分)数据插入~数据库里没数据

cc77077 2006-08-24 01:31:23
<%@LANGUAGE="VBSCRIPT" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<div align="center">
<p> </p>

<form name="form1" method="post" action="">
<p>
<input name="mac" type="text">
</p>
<p> <input type="text" name="u">
</p>
<p>
<input type="submit" name="Submit" value="提交">
</p>
</form>
<p> </p>
</div>
<%


dim mac=request("mac")
dim u=request("u")
sql="insere into Soft(mac,u) values('"&mac&"','"&u&"')"
set conn=Server.CreateObject("ADODB.Connection")
DBpath=Server.MapPath("Soft.mdb")
conn.Open("driver={Microsoft Access Driver (*.mdb)}; dbq="+DBPath)
conn.Execute(sql)
conn.Close

%>
</body>
</html>

哪里出问题了
...全文
557 41 打赏 收藏 转发到动态 举报
写回复
用AI写文章
41 条回复
切换为时间正序
请发表友善的回复…
发表回复
chengxin20050313 2006-08-25
  • 打赏
  • 举报
回复
以我的经验,我通常不用INSERT 语句!

插入数据库是直接插入的!
chengxin20050313 2006-08-25
  • 打赏
  • 举报
回复
?????
xzr2004 2006-08-24
  • 打赏
  • 举报
回复
vbs中好像不能这样直接赋值吧
dim mac=request.form("mac")
dim u=request.form("u")

这样
dim mac,u
mac=request.form("mac")
u=request.form("u")
xzr2004 2006-08-24
  • 打赏
  • 举报
回复
够粗心的
conn.Open("driver={Microsoft Access Driver (*.mdb)}; dbq="+DBPath)

这里改为conn.Open("driver={Microsoft Access Driver (*.mdb)}; dbq="&DBPath)
penglewen 2006-08-24
  • 打赏
  • 举报
回复
if request.Form("submited")<>"" then
end if把这两句不要 看看............
cc77077 2006-08-24
  • 打赏
  • 举报
回复
我用了response.write随便输出几个字也没显示出来过 比如response.write("山豆根撒个大撒个似的爱国上个个") 也都没显示过
penglewen 2006-08-24
  • 打赏
  • 举报
回复
这说明根本没有把数据转过来..........你看看是那里出错了.还有就是数据库有没有连接正确
cc77077 2006-08-24
  • 打赏
  • 举报
回复
我用了response.write 没东西输出到页面上这是怎么回事
leohuang 2006-08-24
  • 打赏
  • 举报
回复
写代码要细心
if request("submit")<>"" then

penglewen 2006-08-24
  • 打赏
  • 举报
回复
帮你分了两个文件来做,如果还是不行的话,你就把每个值都用response.write 输出来看看有没有.或检查一下是不是数据库没连接成功.
<body>
<div align="center">
<form name="form1" method="post" action="save.asp">
<input type="text" name="mac">


<input type="text" name="u">


<input type="submit" name="submited" value="提交">
</form>
<p> </p>


<p> </p>
</div>

</body>
</html>
save.asp
<%
if request.Form("submited")<>"" then
dim mac=request.form("mac")
dim u=request.form("u")
sql="insert into TanIESoft(mac,u) values('"&mac&"','"&u&"')"
set conn=Server.CreateObject("ADODB.Connection")
DBpath=Server.MapPath("TanIESoft.mdb")
conn.Open("driver={Microsoft Access Driver (*.mdb)}; dbq="+DBPath)
conn.Execute(sql)
end if
%>
cc77077 2006-08-24
  • 打赏
  • 举报
回复
<%@LANGUAGE="VBSCRIPT" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<div align="center">
<form name="form1" method="post" action="">
<input type="text" name="mac">


<input type="text" name="u">


<input type="submit" name="Submit" value="提交">
</form>
<p> </p>


<p> </p>
</div>
<%

if request(submit)<>"" then
dim mac=request("mac")
dim u=request("u")
sql="insert into TanIESoft(mac,u) values('"&mac&"','"&u&"')"
set conn=Server.CreateObject("ADODB.Connection")
DBpath=Server.MapPath("TanIESoft.mdb")
conn.Open("driver={Microsoft Access Driver (*.mdb)}; dbq="+DBPath)
conn.Execute(sql)

end if

%>
</body>
</html>
我这样该了还是不行啊
邦迪代驾 2006-08-24
  • 打赏
  • 举报
回复
楼主还是分二页吧,页a.asp入form表单,
页b.asp放处理代码,这个对刚学比较好
pcj2008 2006-08-24
  • 打赏
  • 举报
回复
action不对。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
飘零雾雨 2006-08-24
  • 打赏
  • 举报
回复
1.action没有指向处理URL
2.关键字Insert写错
3.记录集没有open
penglewen 2006-08-24
  • 打赏
  • 举报
回复
湊个热闹............
if request(submit)<>"" then
dim mac=request("mac")
dim u=request("u")
sql="insert into Soft(mac,u) values('"&mac&"','"&u&"')"
set conn=Server.CreateObject("ADODB.Connection")
DBpath=Server.MapPath("Soft.mdb")
conn.Open("driver={Microsoft Access Driver (*.mdb)}; dbq="+DBPath)
conn.Execute(sql)
conn.Close
end if
flyingsnowy 2006-08-24
  • 打赏
  • 举报
回复
粗心比较多一点嘛。
sanney 2006-08-24
  • 打赏
  • 举报
回复
上面这个也一样粗心,和楼主一样~
明珠佩佩 2006-08-24
  • 打赏
  • 举报
回复
需要判断是否从按钮提交过来

否则页面每次加在的时候就会执行数据库操作

记录集都关闭了当然会出错咯
<%
'---------------------------------------------------------
if Request.ServerVariables("Request_Method") = "POST" then
'---------------------------------------------------------

dim mac=request("mac")
dim u=request("u")
sql="insere into Soft(mac,u) values('"&mac&"','"&u&"')"
set conn=Server.CreateObject("ADODB.Connection")
DBpath=Server.MapPath("Soft.mdb")
conn.Open("driver={Microsoft Access Driver (*.mdb)}; dbq="+DBPath)
conn.Execute(sql)
conn.Close

'---------------------------------------------------------
end if
'---------------------------------------------------------
%>


jspadmin 2006-08-24
  • 打赏
  • 举报
回复
楼主够粗心的
insnowind 2006-08-24
  • 打赏
  • 举报
回复
可以做个反面教材
加载更多回复(19)

28,391

社区成员

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

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