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

首頁 > 開發 > 綜合 > 正文

連接SQL SERVER公共類

2024-07-21 02:22:29
字體:
來源:轉載
供稿:網友
'*****************************************************************************************************

option explicit on  

'option strict on

'//***************************************************************************************************

imports system.data.sqlclient


'//***************************************************************************************************

'//begin defined namespace

namespace sunerp.commclass.comm


    '//defined structure  publicapplicationval

    '//structure descriptoin

    '//本結構存取 數據庫服務器名(dbserver)、數據庫用戶id(userid)、

    '//數據庫用戶密碼(userpwd)、數據庫名(dbase),為聯接數據庫提供參數。

    '//為了滿足某些簡單查詢的需要,提供了擴展的變量 常用表名(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的通用函數**//

        '//本函數創建一個到指定數據庫的連接對象 sqlconnection  

        '//本函數有1個參數,ipublicapplication 為公共數據結構 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的通用函數**//

        '//本函數創建一個到指定數據庫的連接對象 sqlconnection  

        '//本函數有1個參數,ipublicapplication 為公共數據結構 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(創建連接的狀態)

        ''true(創建成功),false(創建失?。?

        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

        '//本結構存取 企業組織機構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的通用函數**//

        '//本函數創建一個到指定數據庫的連接對象 sqlconnection  

        '//本函數有1個參數,ipublicapplication 為公共數據結構 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

'*************************************************************************************************** 
  • 本文來源于網頁設計愛好者web開發社區http://www.html.org.cn收集整理,歡迎訪問。
  • 發表評論 共有條評論
    用戶名: 密碼:
    驗證碼: 匿名發表
    主站蜘蛛池模板: 白河县| 蒙自县| 南投县| 安泽县| 伊通| 宜城市| 嵩明县| 大城县| 灵丘县| 衡山县| 正宁县| 河东区| 新闻| 大宁县| 沂源县| 沅江市| 克什克腾旗| 姚安县| 吉隆县| 西和县| 安塞县| 科尔| 桐庐县| 景泰县| 读书| 巴塘县| 亳州市| 吴忠市| 迁西县| 通州区| 辽宁省| 边坝县| 永德县| 达日县| 沙田区| 高清| 柳江县| 汨罗市| 桐梓县| 汶川县| 台中市|