如何用ASP實(shí)現(xiàn)對ORACLE數(shù)據(jù)庫的操作(2)_ASP教程
推薦:淺析ASP中的Debug類--VBScript不知道用ASP寫代碼的朋友是不是和我有一樣的感受,ASP中最頭疼的就是調(diào)試程序的時候不方便,我想可能很多朋友都會用這樣的方法“response.write ”,然后輸出相關(guān)的語句來看看是
通訊錄
| 以下為引用的內(nèi)容:
NAME ADDRESS PHONE EMAIL張玲 馬鞍山市湖北路5號 0555-2887765 [email protected]林向 馬鞍山市湖南路9號 0555-2223856 [email protected]鄧國虹 采礦路子4幢504號 0555-2474748 [email protected]李城 青島海洋大學(xué)7幢507 0464-32456678 [email protected]王國在 采礦小區(qū)7幢807號 0555-3445454 [email protected]丁剛 紅旗南路17幢405號 0555-2883721 [email protected]全在保 江西路子7幢607號 0554-4566777 [email protected] |
(2)插入自己的信息:用ASP將用戶在瀏覽器上提供的數(shù)據(jù)插入到數(shù)據(jù)庫通訊錄表(TSB1)中,由ORACLE數(shù)據(jù)庫有一套完整性約束機(jī)制,所以插入過程不光是簡單地把數(shù)據(jù)插入到表中,還要做完整性約束的檢查,不合要求的數(shù)據(jù)拒絕插入,如果在程序中不考慮處理,運(yùn)行時,就會因數(shù)據(jù)庫服務(wù)器報錯而中斷程序。而ASP中的ERR對象可以報出錯誤來源、錯誤代碼、錯誤說明等,并能把程序引向錯誤處理。
以下是程序,一個是insert.htm, 是一個輸入界面,供用戶輸入自己的信息,一個是insert.asp,負(fù)責(zé)將用戶輸入信息插入數(shù)據(jù)庫,并進(jìn)行錯誤檢查。
| 以下為引用的內(nèi)容:
Insert.htm:< html > < head > < meta http-equiv="Content-Language" content="zh-cn" > < meta http-equiv="Content-Type" content="text/html; charset=gb2312" > < meta name="GENERATOR" content= "Microsoft FrontPage 4.0" > < meta name="ProgId" content= "FrontPage.Editor.Document" > < title >請留下你的信息< /title > < /head > < body > < p align="center" >請輸入你的信息< /p > < form method="post" action="insert.asp" >姓 名:< input type="text" name="name" size="8" > < br >地 址:< input type="text" name="address" size="20" > < br >電 話:< input type="text" name="phone" size="20" > < br > E-MAIL:< input type="text" name="email" size="20" > < br > < input type="submit" value="確定" > < input type="reset" value="取消" >< br > < /form > < /body > < /html > |
下面是用戶輸入界面:
| 以下為引用的內(nèi)容:
請輸入你的信息姓名: 地址: 電話: E-MAIL: Insert.asp:< HTML > < BODY > < % 連接數(shù)據(jù)庫 set orasession=createobject("OracleInprocServer.XOraSession") set oradatabase=orasession. dbopendatabase("axp03","scott/tiger",0) 把用戶插入信息變成SQL語句 sql="insert into tsb1 values(" &chr(39)&request("name")&chr(39) &","_ &chr(39)&request("ADDRESS")&chr(39)&","_ &chr(39) & request("phone")&chr(39) &","_ &chr(39)&request("EMAIL")&chr(39)&")" 運(yùn)行SQL插入語句 oradatabase.dbEXECUTESQL(sql) 檢查是否有違反完整性約束錯誤 IF ERR.NUMBER >0 THEN response.write"< h4 >asp 錯誤控制 < /h4 >" response.write"asp 錯誤來源:"&err.source &"< br >" response.write"asp 錯誤代碼:"&err.number&"< br >" response.write"asp 錯誤說明:"&err.description&"< br >" ELSE 插入完成,返回 |
| 以下為引用的內(nèi)容:
response.write"插入完成,< a href=insert.htm > 返回……< /a >" end if % > < /body > < /html > |
分享:解讀ASP網(wǎng)站Server object error的方法癥狀: 訪問asp網(wǎng)頁的時候出現(xiàn)如下錯誤: Server object error ''ASP 0178 : 80070005'' Server.CreateObject Access Error /_fpclass/fpdbrgn1.inc, line 99 The call to Server.C
- asp FSO 讀寫文件本文件實(shí)現(xiàn)代碼
- asp中isNull、isEmpty和空字符串的區(qū)別
- asp獲取用戶真實(shí)IP地址的方法
- asp連接sqlserver數(shù)據(jù)庫實(shí)現(xiàn)代碼
- asp中正則表達(dá)式過濾html代碼函數(shù)
- asp中g(shù)et post提交表單區(qū)別
- 網(wǎng)頁模板:ASP內(nèi)建對象Request
- xmlhttp的open方法使用詳解
- ASP的常用的自定義函數(shù)大全
- asp中用for循環(huán)的一個小技巧
- eWebEditor v3.8 列目錄
- ASP無組件分頁實(shí)現(xiàn)思路及代碼
- 相關(guān)鏈接:
- 教程說明:
ASP教程-如何用ASP實(shí)現(xiàn)對ORACLE數(shù)據(jù)庫的操作(2)
。