Re: [問題] ASP與資料庫的問題

看板Web_Design作者 (fish)時間19年前 (2006/07/07 05:11), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《drlai (蘇打)》之銘言: : 第一次使用ASP與資料庫結合作登入系統 : 想請問一下 : 我現在想要作使用者的帳號密碼比對 : 大概是這樣的語法 : sql = "select * from usr where username='someone' and passwd='noone'" : 但如果查不到這個使用者及密碼的時候,會出現ASP的錯誤畫面 : 那我該怎麼知道說資料查詢時是否有正確的查到資料呢? : set rs = Conn.Execute(sql) <--執行這行OK : 但因為rs得不到資料 : 所以rs("passwd")時會發生錯誤@@~~ If rs.eof or rs.bof Then Response.Write "沒有這筆資料" Response.End Else '秀出密碼 Response.Write rs("passwd") End If 另外你這樣寫會有 sql injection 的問題 最好過濾一下特殊符號或是換個寫法 -- http://www.wretch.cc/blog/dingyuchi -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.166.99.44 ※ 編輯: dingyuchi 來自: 218.166.99.44 (07/07 05:30)
文章代碼(AID): #14hNnaU6 (Web_Design)
討論串 (同標題文章)
文章代碼(AID): #14hNnaU6 (Web_Design)