国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 晴隆县| 濉溪县| 华容县| 香港 | 荣成市| 始兴县| 宝应县| 陕西省| 赣州市| 新宾| 苏尼特左旗| 项城市| 鄯善县| 七台河市| 娄底市| 闸北区| 阳信县| 正安县| 新田县| 吉水县| 海宁市| 屏东市| 乃东县| 汶川县| 肇庆市| 皋兰县| 浙江省| 得荣县| 耿马| 富阳市| 英山县| 马公市| 库伦旗| 阿拉善盟| 呼图壁县| 天水市| 广汉市| 兴文县| 龙胜| 泰来县| 孟村|