*************************************************************************
'//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
Public Class OrganComm
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
'*******************************************************************************