问题描述
一注册<html><head><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/><title>注册页面</title><styletype="text/css"><!--body{margin-top:0px;margin-bottom:0px;background-image:url();background-repeat:no-repeat;}.STYLE1{color:#FF0000}--></style></head><body><tablewidth="800"height="597"border="0"align="center"cellspacing="0"><tr><tdheight="597"align="center"valign="top"><tablewidth="800"border="0"cellspacing="0"><tr><tdwidth="91"height="114"> </td><tdwidth="310"> </td><tdwidth="304"align="center"valign="bottom"> </td><tdwidth="87"> </td></tr><tr><tdheight="74"> </td><tdcolspan="2"> </td><td> </td></tr><tr><tdheight="205"> </td><tdcolspan="2"bgcolor="#F9F9F9"><formid="form1"name="form1"method="post"action="result.asp"><tablewidth="90%"border="1"align="center"cellpadding="5"cellspacing="0"><tr><tdcolspan="3">请在下面填写您的注册资料,红色<spanclass="STYLE1">*</span>号所标示的选项为必填项</td></tr><tr><tdwidth="24%"align="right">用户名:</td><tdwidth="37%"align="left"><inputname="f_user"type="text"id="f_user"/></td><tdwidth="39%"align="left"><spanclass="STYLE1">*</span></td></tr><tr><tdalign="right">密码:</td><tdalign="left"><inputname="f_code"type="password"id="f_code"/></td><tdalign="left"><spanclass="STYLE1">*</span></td></tr><tr><tdalign="right">姓名:</td><tdalign="left"><inputname="f_name"type="text"id="f_name"/></td><tdalign="left"><spanclass="STYLE1">*</span></td></tr><tr><tdalign="right">性别:</td><tdalign="left"><selectname="f_sex"id="f_sex"><optionvalue="男"selected="selected">男</option><optionvalue="女">女</option></select></td><tdalign="left"><spanclass="STYLE1">*</span></td></tr><tr><tdalign="right">年龄:</td><tdalign="left"><inputname="f_age"type="text"id="f_age"size="8"/></td><tdalign="left"><spanclass="STYLE1">*</span></td></tr><tr><tdcolspan="3"align="center"><inputtype="submit"name="Submit"value="提交注册资料"/> <inputtype="reset"name="Submit2"value="重置表单"/></td></tr></table></form></td><td> </td></tr><tr><tdheight="69"> </td><tdcolspan="2"> </td><td> </td></tr></table></td></tr></table></body></html>二、注册提交后处理的程序:result.asp<!--#includefile="db.inc.asp"--><html><head><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/><title>注册结果</title><styletype="text/css"><!-body{margin-top:0px;margin-bottom:0px;background-image:url();background-repeat:no-repeat;}--></style></head><body><%onerrorresumenext%><tablewidth="800"border="0"align="center"cellspacing="0"><tr><tdwidth="218"height="72"> </td><tdwidth="376"> </td><tdwidth="200"> </td></tr><tr><td> </td><tdalign="center"valign="middle"><%'创建Recordset的对象方法1setrst=server.CreateObject("ADODB.recordset")rst.open"select*fromuserwhereu_user='"&request.form("f_user")&"'",conn,1,1ifrst.recordcount>0thenresponse.Write"用户名:"&request.Form("f_user")&"已经被占用,请从新注册!"rst.closesetrst=nothingconn.closesetconn=nothingresponse.Endelserst.closeconn.begintrans'开启事务,在对数据进行操作前开启rst.open"user",conn,1,3rst.addnewrst("u_user")=request.Form("f_user")rst("u_code")=request.Form("f_code")rst.updaterst.close'获取刚才插入数据的自动编号字段值,u_id字段的值'setrst1=conn.execute("select@@identityasuid")uid=rst1("uid")rst.open"info",conn,1,3rst.addnew'插入数据到info表rst("i_uid")=uidrst("i_name")=request.Form("f_name")rst("i_sex")=request.Form("f_sex")rst("i_age")=request.Form("f_age")rst("i_vip")=falserst.updaterst.closeiferr.number<>0thenconn.rollbacktrans'数据操作出错,取消事务并结束%><imgsrc="1.jpg"width="113"height="69"/><br><%elseconn.committrans'数据操作成功,保存事务并关闭%><imgsrc="2.jpg"width="113"height="69"/><%endifendif%></td><td> </td></tr><tr><tdheight="154"> </td><td> </td><td> </td></tr></table><%setrst=nothingconn.closesetconn=nothing%></body></html>三,数据库<%Dimconnstrconnstr="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&Server.MapPath("Equ.mdb")Setconn=Server.CreateObject("ADODB.Connection")conn.openconnstr%>有人告诉我把result.asp中的,rst.open"select*fromuserwhereu_user='"&request.form("f_user")&"'",conn,1,1user加上[],后,我在办公室的电脑上运行总是提示注册失败的图片。而在我家里的电脑上却总提示:未指定的错误db.inc.asp,第6行我总觉得这一行没有错误呀。请高手指点。
解决方案
解决方案二:
用rst.recordcount的话,要rst.CursorLocation=3setrst=server.CreateObject("ADODB.recordset")rst.CursorLocation=3rst.open"select*from[user]whereu_user='"&request.form("f_user")&"'",conn,1,1ifrst.recordcount>0then---------------------------未指定的错误db.inc.asp,第6行conn.openconnstr数据库连接可能有问题,可能是权限问题命令行窗口执行cacls"c:xxx*.*.mdb"/T/E/GEveryone:F
解决方案三:
写错了是cacls"c:xxx*.*"/T/E/GEveryone:F
解决方案四:
我按你的方法添加后在下面这条语句上又报错:rst.open"user",conn,1,3提示说:无效的SQL语句;期待'DELETE'、'INSERT'、'PROCEDURE'、'SELECT'、或'UPDATE'。其中:user为数据库中的表名.这个语句应该怎么写呢,改成[user]后,提示:参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。这些语句我是看了FIF教程照抄的,怎么有这么多错呀??
解决方案五:
rst.open"user",conn,1,3一般不要这么写,不如写成rst.open"SELECT*FROM[user]WHERE1=0",conn,1,3