程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> 關於ASP編程 >> asp 數據庫連接代碼與數據庫關閉代碼

asp 數據庫連接代碼與數據庫關閉代碼

編輯:關於ASP編程

     dim conn,rs;//這裡如果是調用外部文件就必須定義這裡
    這裡是數據庫創建聯連方法

        sub opendb()
            set rs=server.CreateObject("adodb.recordset")
            set conn=server.CreateObject("adodb.connection")
            conn.connectionstring="provider=microsoft.jet.oledb.4.0; data source="&server.mappath("datasource/hhinfo.mdb")
            conn.open
        end sub

    //這裡是asp數據關閉方法
        sub closedb()
            if isobject(rs) then
                if not(rs is nothing) then
                    rs.close
                    set rs=nothing
                end if
            end if
            if isobject(conn) then
                if not(conn is nothing) then
                    conn.close
                    set conn=nothing
                end if
            end if
        end sub

    1. 上一頁:
    2. 下一頁:
    Copyright © 程式師世界 All Rights Reserved