ASP初学者常犯的几个错误
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 -------------------------------------
------------------------------------
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权限而引起的 不能更新。数据库或对象为只读"错误。
说明:
WI
顶一下
(1)
100%
踩一下
(0)
0%
- 上一篇:session的用法具体解说
- 下一篇:ASP进阶学习必经之认识数学函数11种
- 最新评论 查看所有评论
-
- 发表评论 查看所有评论
-
2012 cheap ugg ugg uggs uggs ugg ugg uggs ugg ugg ugg uggs boots ugg ugg UGGS boots uggs boots. tory burch shoes tory burch outlet for sale.
