ASP初学者常犯的几个错误
来源:互联网 发布:网易撞库数据下载 编辑:程序博客网 时间:2024/04/28 05:18
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权限而引起的 不能更新。数据库或对象为只读"错误
------------------------------------
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权限而引起的 不能更新。数据库或对象为只读"错误
- ASP初学者常犯的几个错误
- ASP初学者常犯的几个错误
- ASP初学者常犯的几个错误
- ASP初学者常犯的几个错误
- ASP初学者常犯的几个错误
- ROR初学者常犯的低级错误
- Java初学者常犯的错误
- 常犯的几个低级错误
- 我常犯的几个小错误
- java程序员常犯的几个错误
- Java程序员常犯的几个错误
- 新手程序员常犯的几个错误
- php初学者容易犯的几个错误
- php初学者容易犯的几个错误
- 避免CSS初学者常犯的那些错误
- 常犯的错误
- 常犯的错误
- 数据分析常犯的几个错误(一)
- Windows操作系统 常用网络命令使用技巧详解
- 少上课,多写论文才是正道
- [读书笔记] 数据库设计基础
- 下定决心,选教材
- cppunit 的使用
- ASP初学者常犯的几个错误
- [intro]erwin /PowerDesigner
- 推荐大家使用Ubuntu Linux 6.06 LTS
- Linux_第6章VI的使用
- Linux 上实现双向进程间通信管道
- C#问题
- 利用存储过程进行批量数据添加
- mvc
- Linux网卡驱动程序在哪里?