| 
 | 
asp常见错误 |  
| Author:咖啡虫 PublishTime:2004-6-8 |  
                 ASP初学者常犯的几个错误 (1)记录集没有关闭之前再次打开:    ————————————————————————     例:    sql="select * from biao1"    rs.open sql,conn,1,3    if rs.eof then      dim name     name=rs("name")   end if   sql="select * from biao2"   rs.open sql,conn,1,3   解决的办法有两个一个是         1。在第二次rs.open之前先关闭 rs.close    或       2。  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 —————————————— (哈哈这个错误我到没有怎么犯啊!因为我的老师(“孙静伟”)没有见过他用锁定方式所以我也没有用啊!不过后来我查资料知道啊!一直用"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 出错提示
      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)
 
 
 
 
 
 
    |  
| 
 |    |    |