jm117 发表于 2007-7-1 19:53

急! 记录添加无内容显示???

我编写了如下代码,希望向数据库中添加四个字段的记录,但是添加后只能看到数据库中记录号增加,看不到任何记录内容??请高手赐教!<BR>代码如下:<BR><FONT color=#3300ff>&lt;table width="217" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#0099FF"&gt;<BR>  &lt;tr&gt;<BR>    &lt;td width="213" height="155"&gt;&lt;form name="form1" method="post" action=""&gt;<BR>      &lt;label&gt;姓名:<BR>        &lt;input name="name" type="text" id="name"&gt;<BR>        &lt;/label&gt;<BR>    &lt;/form&gt;<BR>    &lt;span class="STYLE1"&gt;&lt;/span&gt;<BR>    &lt;form name="form2" method="post" action="index.asp""&gt;<BR>      &lt;label&gt;性别:<BR>        &lt;input name="sex" type="text" id="sex"&gt;<BR>        &lt;/label&gt;<BR>    &lt;/form&gt;<BR>    &lt;form name="form3" method="post" action=""&gt;<BR>      &lt;label&gt;年龄:<BR>        &lt;input name="age" type="text" id="age"&gt;<BR>        &lt;/label&gt;<BR>    &lt;/form&gt;<BR>    &lt;form name="form4" method="post" action=""&gt;<BR>      &lt;label&gt;籍贯:<BR>        &lt;input name="where" type="text" id="where"&gt;<BR>        &lt;/label&gt;<BR>    &lt;/form&gt;<BR>    &lt;form name="form5" method="post" action=""&gt;<BR>      &lt;label&gt;<BR>      &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;<BR>      &lt;input name="Submit1" type="submit" id="Submit1" value="提交"&gt;<BR>      &lt;/label&gt;<BR>      &lt;label&gt;<BR>        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;<BR>        &lt;input name="Submit2" type="reset" id="Submit2" value="重置"&gt;<BR>        &lt;/label&gt;<BR>    &lt;/form&gt;<BR>    &lt;/td&gt;<BR>  &lt;/tr&gt;<BR>&lt;/table&gt;<BR></FONT><FONT color=#ff0000>&lt;!--#include file="conn.asp"--&gt;<BR>&lt;%<BR>dim sql,name,sex,age,where<BR>set rs=server.createobject("adodb.recordset")<BR>sql="select * from message"<BR>rs.open sql,conn,1,3<BR>rs.addnew<BR>rs("name")=request.Form("name")<BR>rs("sex")=request.Form("sex")<BR>rs("age")=request.Form("age")<BR>rs("where")=request.Form("where")<BR>rs.update<BR>rs.close<BR>conn.close<BR>set rs=nothing<BR>set conn=nothing<BR>response.write("记录添加成功")<BR>%&gt;<BR></FONT><FONT color=#000000>蓝色代码为设计表单代码,红色为ASP记录添加代码,其中message为表的名称</FONT>

madpbpl 发表于 2007-7-10 19:38

<P>你这样写代码的方法不对。<BR>&lt;table width="217" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#0099FF"&gt;<BR>  &lt;tr&gt;<BR>    &lt;td width="213" height="155"&gt;<BR>     &lt;form name="form1" method="post" action="<FONT color=#f73809>这里填你红色asp文件名字(比如说1.asp)</FONT>"&gt;<BR>      &lt;label&gt;姓名:<BR>        &lt;input name="name" type="text" id="name"&gt;<BR>        &lt;/label&gt;<BR>    <BR>    &lt;span class="STYLE1"&gt;&lt;/span&gt;<BR>          &lt;label&gt;性别:<BR>        &lt;input name="sex" type="text" id="sex"&gt;<BR>        &lt;/label&gt;<BR>             &lt;label&gt;年龄:<BR>        &lt;input name="age" type="text" id="age"&gt;<BR>        &lt;/label&gt;<BR>              &lt;label&gt;籍贯:<BR>        &lt;input name="where" type="text" id="where"&gt;<BR>        &lt;/label&gt;<BR>             &lt;label&gt;<BR>      &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;<BR>      &lt;input name="Submit1" type="submit" id="Submit1" value="提交"&gt;<BR>      &lt;/label&gt;<BR>      &lt;label&gt;<BR>        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;<BR>        &lt;input name="Submit2" type="reset" id="Submit2" value="重置"&gt;<BR>        &lt;/label&gt;<BR>    &lt;/form&gt;<BR>    &lt;/td&gt;<BR>  &lt;/tr&gt;<BR>&lt;/table&gt;<BR></P>

jm117 发表于 2007-7-10 23:43

问题得以解决,谢谢!

页: [1]

编程论坛