国产探花免费观看_亚洲丰满少妇自慰呻吟_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收集整理,歡迎訪問。
  • 發表評論 共有條評論
    用戶名: 密碼:
    驗證碼: 匿名發表
    主站蜘蛛池模板: 涞水县| 洛宁县| 曲阜市| 夹江县| 汕头市| 长沙县| 阿勒泰市| 宜宾市| 永州市| 渝中区| 承德县| 莱西市| 西平县| 乐业县| 阜阳市| 房山区| 绥芬河市| 汝阳县| 读书| 清丰县| 大悟县| 临汾市| 南澳县| 绿春县| 克什克腾旗| 佛学| 亳州市| 东光县| 黄平县| 名山县| 郴州市| 肥城市| 高碑店市| 长顺县| 浮梁县| 全州县| 万盛区| 琼海市| 黄石市| 和林格尔县| 丰镇市|