一、刪除記錄
opendataconn '打開(kāi)數(shù)據(jù)庫(kù)連接
xxlb=RtnReplaceInt(Trim(request("xxlb")),0) '從里到外依次是接收xxlb變量,去除變量?jī)啥说目崭?最外層是一個(gè)自定義函數(shù),估計(jì)與替換有關(guān)。
id=changechr(request("id")) '接收id,并轉(zhuǎn)換成字符串
ids=split(id,",") '把id按 "," 分割,并保存到數(shù)組ids中
for i=0 to ubound(ids) '用for循環(huán)遍歷數(shù)組
tt=trim(ids(i)) '數(shù)組元素去除兩端空格后賦值給tt
conn.execute"delete from house where id="&tt&"" '刪除數(shù)據(jù)表中id=tt變量的記錄
next '循環(huán)結(jié)束
response.redirect "house.asp?xxlb="&xxlb&"" '跳轉(zhuǎn)到house頁(yè)面并用get方法傳遞xxlb參數(shù),值為xxlb變量的值.
closedataconn 關(guān)閉數(shù)據(jù)庫(kù)連接
二、連接數(shù)據(jù)庫(kù)
dim conn '定義變量
dim char_str(20) '定義數(shù)組
sub OpenDataConn() '自定義過(guò)程,用戶鏈接數(shù)據(jù)庫(kù)地
dim connstr 定義變量
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
connstr = connstr & Server.MapPath("../../data/fyhouse_free.mdb") '數(shù)據(jù)庫(kù)驅(qū)動(dòng)字符串
'response.write connstr 輸出變量connstr的值
set conn=Server.CreateObject("AdoDb.Connection") '創(chuàng)建連接對(duì)象
conn.Open connstr '鏈接數(shù)據(jù)庫(kù)
end sub 這句是過(guò)程的結(jié)束語(yǔ),但從你貼出來(lái)的代碼來(lái)看并沒(méi)有開(kāi)頭。
更多信息請(qǐng)查看IT技術(shù)專欄