1.記錄集關(guān)閉之前再次打開:
------------------------------------
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之前先關(guān)閉?rs.close
或
set?rs1=server.createobject
rs1.open?sql,conn,1,1
2,用SQL關(guān)鍵字做表名或字段名
-------------------------------------
sql="select?*?from?user"
rs.open?sql,conn,1,1
-------------------------------------
user為sql關(guān)鍵字
解決:改為
sql="select?*?from?[user]"
3,用鎖定方式去進(jìn)行update
-------------------------------------
sql="select?*?from?[user]"
rs.open?sql,conn,1,1
rs.addnew
或
rs("userName")="aa"
rs.update
-------------------------------------
當(dāng)前記錄集的打開方式為只讀
解決:
改為
rs.open?sql,conn,1,3
4,在查詢語句中采用的對(duì)比字段值與字段類型不符
-----------------------------------------
sql="select?*?from?[user]?where?id='"?&?myID?&?"'"
rs.open?sql,conn,1,1
-----------------------------------------
假設(shè)表中設(shè)計(jì)ID為數(shù)字型,那么些時(shí)出錯(cuò)。
解決:
sql="select?*?from?[user]?where?id="?&?myID
5,未檢查變量值而出錯(cuò)
-----------------------------------------
sql="select?*?from?[user]?where?id="?&?myID
rs.open?sql,conn,1,1
-----------------------------------------
假設(shè)myID變量此時(shí)值為null,那么sql將成為
sql="select?*?from?[user]?where?id="
解決:
在前面加上
if?isnull(myID)?then?出錯(cuò)提示
6,未檢查變量值類型而出錯(cuò)
-----------------------------------------
sql="select?*?from?[user]?where?id="?&?myID
rs.open?sql,conn,1,1
-----------------------------------------
假設(shè)id為數(shù)字型,myID變量此時(shí)值不為null,但為字符,比如myID此時(shí)為"aa"
那么sql將成為
sql="select?*?from?[user]?where?id=aa"
解決:
在前面加上
if?isnumeric(myID)=false?then?出錯(cuò)提示
這也可以有效防止?sql?injection?漏洞攻擊。
7,由于數(shù)據(jù)庫文件所在目錄的NTFS權(quán)限而引起的'不能更新。數(shù)據(jù)庫或?qū)ο鬄橹蛔x"錯(cuò)誤。
說明:
WIN2K系統(tǒng)延續(xù)了WINNT系統(tǒng)的NTFS權(quán)限。
對(duì)于系統(tǒng)中的文夾都有默認(rèn)的安全設(shè)置。
而通過HTTP對(duì)WWW訪問時(shí)的系統(tǒng)默認(rèn)用戶是?iusr_計(jì)算機(jī)名?用戶?,它屬于guest組。
當(dāng)通過HTTP訪問時(shí),可以ASP或JSP,也或是PHP或.NET程序?qū)?shù)據(jù)進(jìn)行修改操作:
比如:
當(dāng)打開某一個(gè)文章時(shí),程序設(shè)定,文章的閱讀次數(shù)=原閱讀次數(shù)+1
執(zhí)行
conn.execute("update?arts?set?clicks=clicks+1?where?id=n")
語句時(shí),如果?iusr_計(jì)算機(jī)名?用戶沒有對(duì)數(shù)據(jù)庫的寫權(quán)限時(shí),就會(huì)出錯(cuò).
解決方法:
找到數(shù)據(jù)庫所在目錄
右鍵》屬性》安全選項(xiàng)卡》設(shè)置?iusr_計(jì)算機(jī)名?用戶的寫權(quán)限(當(dāng)然,也可以是everyone)
posted on 2006-08-11 08:44
fly 閱讀(227)
評(píng)論(0) 編輯 收藏 所屬分類:
ASP學(xué)習(xí)