连接SQL SERVER公共类
来源:互联网 发布:linux 类似telnet命令 编辑:程序博客网 时间:2024/06/04 23:35
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
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
'***************************************************************************************************
连接SQL SERVER公共类';return true">
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
'***************************************************************************************************** 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
'***************************************************************************************************
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- 连接SQL SERVER公共类
- 连接SQL SERVER的公共类
- 连接SQL SERVER的公共类
- 连接SQL SERVER的公共类
- 连接SQL SERVER的公共类(VB.NET)
- 连接SQL SERVER的公共类(VB.NET)
- java公共类(连接SQL sever)
- vc++连接SQL SERVER类
- jsp连接sql server类
- sql 类+连接sql server 2005
- 一个操作Sql Server 2000的公共类
- C#——访问SQL Server 2005公共类
- PHP 连接 SQL SERVER 类源程序参考
- 连接到外部sql server工具类
- Java 连接SQL Server 连接
- Perl 连接 SQL Server
- SQL Server 连接基础知识
- 连接SQL Server数据库
- C#学习笔记之五(ADO.net)
- 社区(php&&mysql)三
- 里面是对一个body的属性进行server的一些设定,不过可以衍生到其他的一些htmlcontrol
- 社区(php&&mysql)一
- 关于在连接数据库时候命名管道不工作的官方解决办法
- 连接SQL SERVER公共类
- 社区(php&&mysql)二
- C# v.s java 再贴+评点
- 人大复印资料处理程序_补充篇
- 转新技术网:在ASP.NET中使用.NET组件
- 解决一个.NET联接SQL的问题 yiyang(转贴)
- VS2003开发指南文档----中文
- 自己写的一个资料验证的asp.net程序,大家看看吧!
- dotNET C# Programmer’s Guide to the Win32 API (Win