快帮看看!简单的向数据库添加数据的问题我都不能解决????

pdysuny 2003-05-04 11:11:34
快帮看看!简单的向数据库添加数据的问题我都不能解决????我试向数据库添加数据:
test.asp:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<form name="form1" method="post" action="testsave.asp">
<p>ss
<input name="name" type="text" id="name">
</p>
<p>
<input type="submit" name="Submit" value="提交">
</p>
</form>
</body>
</html>

testsave.asp:
<!--#include file="conn.asp"-->
<%
dim rs
rs=Server.CreateObject("Adodb.Recordset")
sql="select * from test"
rs.open sql,conn,1,3
rs.addnew
rs("name")=Request("name")
rs.update
if not rs.eof then
%>
<table>
<tr>
<td><%=rs("name")%></td>
</tr>
</table>
<%
else
response.write"没有数据"
end if
conn.close
set conn=nothing
rs.close
set rs=nothing
%>
没有任何提示,出现空白页.

...全文
22 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
lu_yanfeng 2003-05-05
  • 打赏
  • 举报
回复
因为VB语言中对象的赋值必须用set
lu_yanfeng 2003-05-05
  • 打赏
  • 举报
回复
rs=Server.CreateObject("Adodb.Recordset")
改为set rs=Server.CreateObject("Adodb.Recordset")
bethzwt 2003-05-04
  • 打赏
  • 举报
回复
rs=Server.CreateObject("Adodb.Recordset")
改为set rs=Server.CreateObject("Adodb.Recordset")
试一下
fangpeng2003 2003-05-04
  • 打赏
  • 举报
回复
name= Request("name")
sql="insert into test(name) values('"&name&"')"
conn.Execute sql

lu_yanfeng 2003-05-04
  • 打赏
  • 举报
回复
conn.execute "INNSERT INTO [test]([name]) VALUES('" & Request("name") & "')"
pdysuny 2003-05-04
  • 打赏
  • 举报
回复
急的满头大汉
pdysuny 2003-05-04
  • 打赏
  • 举报
回复
哎,无论如何数据库里都是空的啊,什么也没有,程序好象没有错啊?为什么呢?
麻烦给一段向数据库添加数据的代码吧!
mingday 2003-05-04
  • 打赏
  • 举报
回复
数据库涮新一下
pdysuny 2003-05-04
  • 打赏
  • 举报
回复
快帮看看吧,这样简单的问题,我真的急死了,我可要面试的.
如何想数据库添加数据??????
pdysuny 2003-05-04
  • 打赏
  • 举报
回复
这样是可以出现了,但是,我看数据库里什么也没有,那又是怎么回事呢?那又怎样向数据库里添加数据啊?
haojei 2003-05-04
  • 打赏
  • 举报
回复
先看看你从表单提交了些什么数据了吧,换个文本框试试,
或者是rs("name")=Request.form("name")
rexsp 2003-05-04
  • 打赏
  • 举报
回复
testsave.asp:
<!--#include file="conn.asp"-->
<%
dim rs

set rs=Server.CreateObject("Adodb.Recordset")
sql="select * from test"
rs.open sql,conn,1,3
rs.addnew
rs("name")=Request("name")
rs.update
%>
<table>
<tr>
<td><%=rs("name")%></td>
</tr>
</table>
<%
else
response.write"没有数据"
end if
conn.close
set conn=nothing
rs.close
set rs=nothing
%>
ShiningstarHu 2003-05-04
  • 打赏
  • 举报
回复

<td><%=rs("name")%></td>
改成:
<td><%=Request("name")%></td>
pdysuny 2003-05-04
  • 打赏
  • 举报
回复
正如你说的,那么怎么解决呢?快告诉我吧,我喊你"老师"了!
ShiningstarHu 2003-05-04
  • 打赏
  • 举报
回复
当你出现空白页的时候请点击右键看看你这个网页的源文件。我估计的得到的源文件是:

<table>
<tr>
<td></td>
</tr>
</table>

因此你看不到任何东西。
pdysuny 2003-05-04
  • 打赏
  • 举报
回复
帮看看吧

28,391

社区成员

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

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