国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

三層架構之數據庫訪問層(VB)

2024-07-21 02:20:43
字體:
來源:轉載
供稿:網友
'########數據庫訪問層##########


'返回一個adocn連接對象

'與c#不同,這里不能關閉連接及釋放內存
public function getcn(sdbpath as string) as adodb.connection


const spro as string = "provider=microsoft.jet.oledb.4.0;data source="
const sdbpwd as string = ";jet oledb:database password=qq:48403849"

dim sdbpath as string
dim m_cn as adodb.connection



set m_cn = new adodb.connection

m_cn.cursorlocation = aduseclient '客戶端游標

if m_cn.state <> adstateclosed then m_cn.close

on error goto conerr

m_cn.open spro & sdbpath & sdbpwd

set getcn = m_cn

exit function
conerr:
set getcn = nothing
msgbox "數據庫連接錯誤", vbcritical

end function

'執行一句sql語句,正確返回 1
public function excutesql(ssql as string) as integer
dim m_cn as new adodb.connection

on error goto err

set m_cn = getcn(sg_dbpath)
m_cn.execute ssql
m_cn.close
set m_cn = nothing
excutesql = 1

exit function
err:
excutesql = 0
set m_cn = nothing


end function
'執行一組sql語句,正確返回1
public function excutesqlex(ssql() as string) as integer
'調用事務處理
dim m_cn as new adodb.connection, i as integer

if ubound(ssql) < 0 then exit function
on error goto err

set m_cn = getcn(sg_dbpath)

m_cn.begintrans
for i = 0 to ubound(ssql) - 1
m_cn.execute ssql(i)
next i

m_cn.committrans
m_cn.close
set m_cn = nothing

excutesqlex = 1

exit function
err:
excutesqlex = 0
m_cn.rollbacktrans
m_cn = nothing

end function


'未完,待補充

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 东宁县| 商都县| 万源市| 丹东市| 巴林左旗| 友谊县| 梅河口市| 天门市| 喜德县| 浦城县| 宁阳县| 贵溪市| 理塘县| 郴州市| 咸丰县| 乌鲁木齐市| 高清| 河源市| 上虞市| 静海县| 仁化县| 泊头市| 安仁县| 远安县| 繁昌县| 陆良县| 垫江县| 蓝田县| 墨江| 新平| 金川县| 白玉县| 罗山县| 梅河口市| 灵寿县| 东至县| 田东县| 温泉县| 乾安县| 汝州市| 宣汉县|