选择显示字体大小

连接sql server的公共类(vb.net)

*************************************************************************
'//开始日期: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

    '//本结构存取 数据库服务器名(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

'*******************************************************************************


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons