| 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)
   |