大家帮我看看,为什么总是报错:未指定的错误,db.inc.asp, 第 6 行
时间:2011-11-23
来源:互联网
一注册
<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" ><table width="800" border="0" cellspacing="0">
<tr>
<td width="91" height="114"> </td>
<td width="310"> </td>
<td width="304" align="center" valign="bottom"> </td>
<td width="87"> </td>
</tr>
<tr>
<td height="74"> </td>
<td colspan="2"> </td>
<td> </td>
</tr>
<tr>
<td height="205"> </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="提交注册资料" />
<input type="reset" name="Submit2" value="重置表单" /></td>
</tr>
</table>
</form></td>
<td> </td>
</tr>
<tr>
<td height="69"> </td>
<td colspan="2"> </td>
<td> </td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
二、注册提交后处理的程序:result.asp
<!--#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>
<% on error resume next %>
<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">
<%
'创建Recordset的对象方法1
set rst=server.CreateObject("ADODB.recordset")
rst.open "select * from user where u_user='" & request.form("f_user") & "'",conn,1,1
if rst.recordcount>0 then
response.Write "用户名:" & request.Form("f_user") &" 已经被占用,请从新注册!"
rst.close
set rst=nothing
conn.close
set conn=nothing
response.End
else
rst.close
conn.begintrans '开启事务,在对数据进行操作前开启
rst.open "user",conn,1,3
rst.addnew
rst("u_user")=request.Form("f_user")
rst("u_code")=request.Form("f_code")
rst.update
rst.close
'获取刚才插入数据的自动编号字段值,u_id字段的值'
set rst1=conn.execute("select @@identity as uid")
uid=rst1("uid")
rst.open "info",conn,1,3
rst.addnew '插入数据到info表
rst("i_uid")=uid
rst("i_name")=request.Form("f_name")
rst("i_sex")=request.Form("f_sex")
rst("i_age")=request.Form("f_age")
rst("i_vip")=false
rst.update
rst.close
if err.number<>0 then
conn.rollbacktrans '数据操作出错,取消事务并结束
%>
<img src="1.jpg" width="113" height="69" /><br>
<% else
conn.committrans '数据操作成功,保存事务并关闭
%>
<img src="2.jpg" width="113" height="69" />
<%
end if
end if
%>
</td>
<td> </td>
</tr>
<tr>
<td height="154"> </td>
<td> </td>
<td> </td>
</tr>
</table>
<%
set rst=nothing
conn.close
set conn=nothing
%>
</body>
</html>
三,数据库
<%
Dim connstr
connstr ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath("Equ.mdb")
Set conn =Server.CreateObject("ADODB.Connection")
conn.open connstr
%>
有人告诉我把result.asp中的,rst.open "select * from user where u_user='" & request.form("f_user") & "'",conn,1,1
user加上[],后,我在办公室的电脑上运行总是提示注册失败的图片。而在我家里的电脑上却总提示:未指定的错误
db.inc.asp, 第 6 行
我总觉得这一行没有错误呀。请高手指点。
<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" ><table width="800" border="0" cellspacing="0">
<tr>
<td width="91" height="114"> </td>
<td width="310"> </td>
<td width="304" align="center" valign="bottom"> </td>
<td width="87"> </td>
</tr>
<tr>
<td height="74"> </td>
<td colspan="2"> </td>
<td> </td>
</tr>
<tr>
<td height="205"> </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="提交注册资料" />
<input type="reset" name="Submit2" value="重置表单" /></td>
</tr>
</table>
</form></td>
<td> </td>
</tr>
<tr>
<td height="69"> </td>
<td colspan="2"> </td>
<td> </td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
二、注册提交后处理的程序:result.asp
<!--#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>
<% on error resume next %>
<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">
<%
'创建Recordset的对象方法1
set rst=server.CreateObject("ADODB.recordset")
rst.open "select * from user where u_user='" & request.form("f_user") & "'",conn,1,1
if rst.recordcount>0 then
response.Write "用户名:" & request.Form("f_user") &" 已经被占用,请从新注册!"
rst.close
set rst=nothing
conn.close
set conn=nothing
response.End
else
rst.close
conn.begintrans '开启事务,在对数据进行操作前开启
rst.open "user",conn,1,3
rst.addnew
rst("u_user")=request.Form("f_user")
rst("u_code")=request.Form("f_code")
rst.update
rst.close
'获取刚才插入数据的自动编号字段值,u_id字段的值'
set rst1=conn.execute("select @@identity as uid")
uid=rst1("uid")
rst.open "info",conn,1,3
rst.addnew '插入数据到info表
rst("i_uid")=uid
rst("i_name")=request.Form("f_name")
rst("i_sex")=request.Form("f_sex")
rst("i_age")=request.Form("f_age")
rst("i_vip")=false
rst.update
rst.close
if err.number<>0 then
conn.rollbacktrans '数据操作出错,取消事务并结束
%>
<img src="1.jpg" width="113" height="69" /><br>
<% else
conn.committrans '数据操作成功,保存事务并关闭
%>
<img src="2.jpg" width="113" height="69" />
<%
end if
end if
%>
</td>
<td> </td>
</tr>
<tr>
<td height="154"> </td>
<td> </td>
<td> </td>
</tr>
</table>
<%
set rst=nothing
conn.close
set conn=nothing
%>
</body>
</html>
三,数据库
<%
Dim connstr
connstr ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath("Equ.mdb")
Set conn =Server.CreateObject("ADODB.Connection")
conn.open connstr
%>
有人告诉我把result.asp中的,rst.open "select * from user where u_user='" & request.form("f_user") & "'",conn,1,1
user加上[],后,我在办公室的电脑上运行总是提示注册失败的图片。而在我家里的电脑上却总提示:未指定的错误
db.inc.asp, 第 6 行
我总觉得这一行没有错误呀。请高手指点。
作者: hsbwp1314 发布时间: 2011-11-23
用 rst.recordcount的话 , 要 rst.CursorLocation = 3
set rst=server.CreateObject("ADODB.recordset")
rst.CursorLocation = 3
rst.open "select * from [user] where u_user='" & request.form("f_user") & "'",conn,1,1
if rst.recordcount>0 then
---------------------------
未指定的错误
db.inc.asp, 第 6 行
conn.open connstr 数据库连接可能有问题 ,可能是 权限问题
命令行窗口执行 cacls "c:\x\xx\*.*.mdb" /T /E /G Everyone:F
set rst=server.CreateObject("ADODB.recordset")
rst.CursorLocation = 3
rst.open "select * from [user] where u_user='" & request.form("f_user") & "'",conn,1,1
if rst.recordcount>0 then
---------------------------
未指定的错误
db.inc.asp, 第 6 行
conn.open connstr 数据库连接可能有问题 ,可能是 权限问题
命令行窗口执行 cacls "c:\x\xx\*.*.mdb" /T /E /G Everyone:F
作者: hookee 发布时间: 2011-11-23
写错了 是 cacls "c:\x\xx\*.*" /T /E /G Everyone:F
作者: hookee 发布时间: 2011-11-23
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28