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

首頁 > 開發(fā) > 綜合 > 正文

連接SQL SERVER的公共類(轉)

2024-07-21 02:25:13
字體:
來源:轉載
供稿:網友
連接sql server的公共類    blestwq(原作)  
  
'*****************************************************************************************************
'//開始日期:2002年5月27日
'//結束日期:2002年5月27日
'*****************************************************************************************************
option explicit on
'option strict on
'//***************************************************************************************************
imports system.data.sqlclient
'//***************************************************************************************************
'//begin defined namespace
namespace sunerp.commclass.comm
    '//defined structure  publicapplicationval
    '//structure descriptoin
    '//本結構存取 數(shù)據庫服務器名(dbserver)、數(shù)據庫用戶id(userid)、
    '//數(shù)據庫用戶密碼(userpwd)、數(shù)據庫名(dbase),為聯(lián)接數(shù)據庫提供參數(shù)。
    '//為了滿足某些簡單查詢的需要,提供了擴展的變量 常用表名(dbtable)、
    '//查詢字段名(queryfieldname)、查詢字段值
    '//begin define structure publicapplicationval
    public structure publicapplicationval
        ' public dbserver, userid userpwd dbase dbtable account.
        public dbserver as string
        public userid as string
        public userpwd as string
        public dbase as string
        public dbtable as string
        public queryfieldvale as string
        public queryfieldname as string
    end structure
    '//end define structure publicapplicationval
    '//***************************************************************************************************   '//***************************************************************************************************
    '//begin defined class
    public class dbasebindcomm
        ''***********************************************************************
        ''//**定義連接sql server database的通用函數(shù)**//
        '//本函數(shù)創(chuàng)建一個到指定數(shù)據庫的連接對象 sqlconnection
        '//本函數(shù)有1個參數(shù),ipublicapplication 為公共數(shù)據結構 publicapplicationval,

        '//begin define function linkedsqlserver
        public overloads function linkedsqlserver() as system.data.sqlclient.sqlconnection

            dim strconn as string
            dim conn as new sqlconnection()
            strconn = "server=" & "erp" & _
                      ";user id=" & "erpsa" & _
                      ";password=" & "erpsa" & _
                      ";database=" & "erpdata" & ";"

            try
                conn = new sqlconnection(strconn)
                conn.open()
                stateval = true
                linkedsqlserver = conn
            catch ex as exception
                ' msgbox(ex.tostring)
                stateval = false
                linkedsqlserver = nothing
                exit function
            end try
        end function


        ''end defined linkedsqlserver
        ''***********************************************************************

        ''***********************************************************************
        ''//**定義連接sql server database的通用函數(shù)**//
        '//本函數(shù)創(chuàng)建一個到指定數(shù)據庫的連接對象 sqlconnection
        '//本函數(shù)有1個參數(shù),ipublicapplication 為公共數(shù)據結構 publicapplicationval,

        '//begin define function linkedsqlserver
        public overloads function linkedsqlserver( _
                 byval ipublicapplication as publicapplicationval) _
                 as system.data.sqlclient.sqlconnection

            dim strconn as string
            dim conn as new sqlconnection()
            strconn = "server=" & ipublicapplication.dbserver & _
                      ";user id=" & ipublicapplication.userid & _
                      ";password=" & ipublicapplication.userpwd & _
                      ";database=" & ipublicapplication.dbase & ";"

            try
                conn = new sqlconnection(strconn)
                conn.open()
                stateval = true
                linkedsqlserver = conn
            catch ex as exception
                ' msgbox(ex.tostring)
                stateval = false
                linkedsqlserver = nothing
                exit function
            end try
        end function
        ''end defined linkedsqlserver
        ''***********************************************************************


        ''定義類dbasebindcomm的readonly屬性state(創(chuàng)建連接的狀態(tài))
        ''true(創(chuàng)建成功),false(創(chuàng)建失敗)
        private stateval as boolean
        public readonly property state() as boolean
            get
                return stateval
            end get
        end property

    end class

    public class organcomm

        '//defined structure  publicorganidstructure
        '//structure descriptoin
        '//本結構存取 企業(yè)組織機構id
        '//頂層(depttopid)、一級(deptmidid),二級id(deptlowid)        

        '//begin define structure publicorganidstructure
        public structure publicorganidstructure
            public depttopid as string
            public deptmidid as string
            public deptlowid as string
        end structure
        '//end define structure publicorganidstructure
        '//***************************************************************************************************        ''***********************************************************************
        ''//**定義連接sql server database的通用函數(shù)**//
        '//本函數(shù)創(chuàng)建一個到指定數(shù)據庫的連接對象 sqlconnection
        '//本函數(shù)有1個參數(shù),ipublicapplication 為公共數(shù)據結構 publicapplicationval,

        '//begin define function iparsedeptorgid
        public function iparsedeptorgid(byval ideptorgid as string) as publicorganidstructure
            dim organid as new publicorganidstructure()
            dim orgid as string

            ideptorgid = trim(ideptorgid)
            orgid = microsoft.visualbasic.left(trim(ideptorgid), 12)

            organid.depttopid = microsoft.visualbasic.left(orgid, 6)
            organid.deptmidid = microsoft.visualbasic.right(orgid, 6)
            organid.deptlowid = microsoft.visualbasic.right(ideptorgid, 6)

            iparsedeptorgid = organid
        end function
        '//end define function iparsedeptorgid

    end class


end namespace


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 旬邑县| 郎溪县| 奉化市| 汝城县| 凌源市| 桂阳县| 龙胜| 同仁县| 灵寿县| 承德市| 武强县| 咸阳市| 南靖县| 庄河市| 兴海县| 左权县| 信宜市| 伽师县| 海宁市| 壤塘县| 宁夏| 武邑县| 化德县| 兴国县| 辽中县| 金沙县| 义马市| 义乌市| 宜君县| 铁岭县| 通山县| 内丘县| 黔江区| 香港| 昂仁县| 高陵县| 徐汇区| 吉木萨尔县| 秦皇岛市| 沂源县| 汶上县|