• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
dlfen
博客园    首页    新随笔    联系   管理    订阅  订阅

ASP初学者常犯的几个错误

1.记录集关闭之前再次打开: ———————————— sql="select * from test" rs.open sql,conn,1,1 if not rs.eof then dim myName myName=rs("name")
1.记录集关闭之前再次打开:
————————————
sql=
"select * from test"
rs.open sql,conn,1,1
if not rs.eof then
dim 
myName
myName=rs(
"name")
end if
sql="select * from myBook"
rs.open sql,conn,1,1
————————————-
解决:在第二次rs.open之前先关闭 rs.close
或
set rs1=server.createobject
rs1.open sql,conn,
1,1

2
,用SQL关键字做表名或字段名
————————————-
sql=
"select * from user"
rs.open sql,conn,1,1
————————————-
user为sql关键字
解决:改为
sql=
"select * from [user]"

3,用锁定方式去进行update
————————————-
sql=
"select * from [user]"
rs.open sql,conn,1,1
rs.addnew
或
rs(
"userName")="aa"
rs.update
————————————-
当前记录集的打开方式为只读
解决:
改为
rs.open sql,conn,
1,3

4
,在查询语句中采用的对比字段值与字段类型不符
—————————————–
sql=
"select * from [user] where id= " & myID & " "
rs.open sql,conn,1,1
—————————————–
假设表中设计ID为数字型,那么些时出错。
解决:
sql=
"select * from [user] where id=" & myID

5,未检查变量值而出错
—————————————–
sql=
"select * from [user] where id=" & myID
rs.open sql,conn,
1,1
—————————————–
假设myID变量此时值为null,那么sql将成为
sql=
"select * from [user] where id="
解决:
在前面加上
if isnull(myID) then 出错提示

6,未检查变量值类型而出错
—————————————–
sql=
"select * from [user] where id=" & myID
rs.open sql,conn,
1,1
—————————————–
假设id为数字型,myID变量此时值不为null,但为字符,比如myID此时为
"aa"
那么sql将成为
sql=
"select * from [user] where id=aa"
解决:
在前面加上
if isnumeric(myID)=false then 出错提示

这也可以有效防止 sql injection 漏洞攻击。

7,由于数据库文件所在目录的NTFS权限而引起的 不能更新。数据库或对象为只读错误。
说明:
WIN2K系统延续了WINNT系统的NTFS权限。
对于系统中的文夹都有默认的安全设置。
而通过HTTP对WWW访问时的系统默认用户是 iusr_计算机名 用户 ,它属于guest组。
当通过HTTP访问时,可以ASP或JSP,也或是PHP或.NET程序对数据进行修改操作:
比如:
当打开某一个文章时,程序设定,文章的阅读次数=原阅读次数+
1
执行
conn.execute(
"update arts set clicks=clicks+1 where id=n")
语句时,如果 iusr_计算机名 用户没有对数据库的写权限时,就会出错.
解决方法:
找到数据库所在目录
右键》属性》安全选项卡》设置 iusr_计算机名 用户的写权限(当然,也可以是everyone) 
…
posted @ 2008-07-17 21:35  七夜鱼  阅读(168)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3