注册 登录
编程论坛 ASP技术论坛

Access 的问题 求教

wrz1788 发布于 2010-10-09 13:21, 541 次点击
刚把注册页面和数据库连接做好 还挺高兴  自己试了试  悲剧了。。。。
注册也面的内容没有写入数据库 注册提交后 数据库u_id倒是在自动编号 可是u_code u_user 都是空的
7 回复
#2
yms1232010-10-09 14:11
代码怎么写的?
#3
wrz17882010-10-09 16:02
回复 2楼 yms123
<!-- #include file="db.inc.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>注册结果</title>
<style type="text/css">
<!-
body {
margin-top: 0px;
margin-bottom: 0px;
background-image: url();
background-repeat: no-repeat;
}
-->
</style></head>
<body>
<table width="800" border="0" align="center" cellspacing="0">
<tr>
<td width="218" height="72"> </td>
<td width="376"> </td>
<td width="200"> </td>
</tr>
<tr>
<td> </td>
<td align="center" valign="middle">
<%
set rst=server.CreateObject("ADODB.recordset")
set rst1=conn.Execute("insert into user (u_user,u_code) values ('" & request.Form("f_user") & "','" & request.form("f_code") & "')")
%>
<img src="img/zcsb.jpg" width="355" height="240" /><br>
<img src="img/zccg.jpg" width="357" height="229" /></td>
<td> </td>
</tr>
<tr>
<td height="154"> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>

这是注册结果的页面




<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>注册页面</title>
<style type="text/css">
<!--
body {
margin-top: 0px;
margin-bottom: 0px;
background-image: url();
background-repeat: no-repeat;
}
.STYLE1 {color: #FF0000}
-->
</style></head>
<body>
<table width="800" height="597" border="0" align="center" cellspacing="0">
<tr>
<td height="597" align="center" valign="top" background="img/beijing.jpg"><table width="800" border="0" cellspacing="0">
<tr>
<td width="91" height="114">&nbsp;</td>
<td width="310">&nbsp;</td>
<td width="304" align="center" valign="bottom"><img src="img/zcym2.jpg" width="257" height="76" /></td>
<td width="87">&nbsp;</td>
</tr>
<tr>
<td height="74">&nbsp;</td>
<td colspan="2">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="322">&nbsp;</td>
<td colspan="2" bgcolor="#F9F9F9"><form id="form1" name="form1" method="post" action="result.asp"><table width="90%" border="1" align="center" cellpadding="5" cellspacing="0">
<tr>
<td colspan="3">请在下面填写您的注册资料,红色<span class="STYLE1">*</span>号所标示的选项为必填项</td>
</tr>
<tr>
<td width="24%" align="right">用户名:</td>
<td width="37%" align="left"><input name="f_user" type="text" id="f_user" /></td>
<td width="39%" align="left"><span class="STYLE1">*</span></td>
</tr>
<tr>
<td align="right">密码:</td>
<td align="left"><input name="f_code" type="password" id="f_code" /></td>
<td align="left"><span class="STYLE1">*</span></td>
</tr>
<tr>
<td align="right">姓名:</td>
<td align="left"><input name="f_name" type="text" id="f_name" /></td>
<td align="left"><span class="STYLE1">*</span></td>
</tr>
<tr>
<td align="right">性别:</td>
<td align="left"><select name="f_sex" id="f_sex">
<option value="男" selected="selected">男</option>
<option value="女">女</option>
</select>            </td>
<td align="left"><span class="STYLE1">*</span></td>
</tr>
<tr>
<td align="right">年龄:</td>
<td align="left"><input name="f_age" type="text" id="f_age" size="8" /></td>
<td align="left"><span class="STYLE1">*</span></td>
</tr>
<tr>
<td colspan="3" align="center">
<input type="submit" name="Submit" value="提交注册资料" />
&nbsp;&nbsp;&nbsp; <input type="reset" name="Submit2" value="重置表单" /></td>
</tr>
</table>
</form>
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="69">&nbsp;</td>
<td colspan="2">&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
这是注册页面   谢谢斑竹了
#4
hams2010-10-09 16:37
找个例子来学习一下吧
#5
魏兴耀2010-10-10 17:07
唉.....这么多行,说实在的,都没耐心看,注册登录的话,你可以简化一下,没必要弄那么多注册行的,少一点的话,你自己看得也方便,先试试,然后再多弄几行。
你的那个页面有什么错误提示不?其实你只要把关键的几行贴上来就好了,连数据库的、表单的、SQL,获取信息的就够了,大概错误也就在那里了
#6
zhanxinlin2010-10-13 23:29
set rst1=conn.Execute("insert into user (u_user,u_code) values ('" & request.Form("f_user") & "','" & request.form("f_code") & "')")
这一行不能这样写的。。。。。。。。
连接好数据库和打开表后,该是这样的
rst1("u_user")=request.form("f_user")
....
#7
jingjing3162010-10-14 11:58
set rst1=conn.Execute("insert into user (u_user,u_code) values ('" & request.Form("f_user") & "','" & request.form("f_code") & "')")
这种语句不是很熟
你分开来写
sql="insert into user (u_user,u_code) values ('" & request.Form("f_user") & "','" & request.form("f_code") & "')"
conn.excute sql
看看能添加进去吗
如果不能
只有本站会员才能查看附件,请 登录

仿照这个例子看看吧
我一般用记录集
rs.addnew
这种
#8
assfy2010-10-18 14:27
set rs=server.createobject("adodb.recordset")
exec="select * from 数据表名 "
rs.open exec,conn,1,3
rs.addnew
rs("对应的字段名")=request.Form("f_user")
rs("对应的字段名")=request.form("f_code")
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
Response.Write("<script language=javascript>alert('注册成功');this.location.href='jszs_admin.asp';</script>")
1