Connect the public class for SQL Server

zhaozj2021-02-16  47

'********************************************************** *********************************************************** ** '// Start Date: May 27, 2002' // End Date: May 27, 2002 '********************** *********************************************************** *************************** OPTION EXPLICIT ON 'OPTION STRICT ON' // ************ *********************************************************** *********************************** Imports system.data.sqlclient

'// ******************************************************** *********************************************************** ** '// begin defined namespacenamespace sunerp.commclass.comm

'// defined structure publicApplicationVal' // structure descriptoin '// This structure Access database server name (DBServer), database user ID (userid),' // Database User Password (UserPwd), Database Name (DBASE), for join The database provides parameters. '// In order to meet the needs of some simple queries, the extended variables, "QueryfieldName, query field value", query field value

'// 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 publicapplicationvalu' // ************************************************** *********************************************************** ********* '// ************************************************ *********************************************************** ********** '// Begin Defined Class Public Class DBasebindcomm' '************************************************************************************************************************************************************************************************************************************ ******************************************** ** definition Connection SQL Server Database general function ** // '// This function creates a connection object to the specified database SqlConnection' // This function has 1 parameter, ipublicapplication is public data structure 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' '* *********************************************************** *******************

'' ********************************************************* *********************** '// ** Define Universal Functions for SQL Server Database ** //' // This function creates one to the specified The connection object of the database SQLConnection '// This function has 1 parameters, ipublicapplication is public data structure publicApplicationVal,

'// begin define function linksqlserver public overloads function linkedsqlserver (_ byval ipublicapplication as publicapplicationvalvalVal) _ 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' '* *********************************************************** ****************** DeadOnly property State (Create success), False (Created) private stat States As Boolean Public Readonly Property State () AS Boolean Get Return StateVal End Get End Property

END CLASS

Public class OrganComm

'// defined structure publicorganidstructure' // Structure descripture '// This structure Access Enterprise Organization ID' // Top (DePTMID), Second Level 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 '// **************** *********************************************************** *********************************************************** *********************************************************** ****** '// ** Define Universal Functions for SQL Server Database ** //' // This function creates a connection object to the specified database SQLConnection '// This function has 1 parameter, ipublicapplication is a common data structure 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.deptmididiD = Microsoft.VisualBasic.right (ORGID, 6) OrganId.DeptlowID = Microsoft.VisualBasic.right (IdeptorgID, 6)

Iparsedeptorgid = organid end function '// end define function iparsedeptorgid

END CLASS

End namespace '*********************************************************** *********************************************************** **

转载请注明原文地址:https://www.9cbs.com/read-25881.html

New Post(0)