?? clsjobsmanager.cls
字號:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "clsJobsManager"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Dim dbm As clsDBManager
'向jobs表里添加數據
Public Function InsertJobs(PjobsI As clsJobsItem)
Dim strSql As String
strSql = "insert into jobs(job_desc,min_lvl,Max_lvl) " _
& "values('" & PjobsI.Job_desc & _
"'," & PjobsI.Min_lvl & "," & PjobsI.Max_lvl & ")"
dbm.ExecSQL strSql
End Function
'刪除數據
Public Function DeleteJobs(PjobsI As clsJobsItem)
Dim strSql As String
strSql = "delete from jobs where 1=1"
If PjobsI.Job_id <> 0 Then
strSql = strSql & " and job_id =" & PjobsI.Job_id
End If
If PjobsI.Job_desc <> "" Then
strSql = strSql & " and job_desc='" & PjobsI.Job_desc & "'"
End If
dbm.ExecSQL strSql
End Function
'查詢數據
Public Function SelectJobs(PjobsI As clsJobsItem, ByRef Prs As ADODB.Recordset) As Collection
Dim strSql As String
strSql = "select * from jobs where 1=1"
Dim Rst As New clsRstSet
Rst.Source = strSql
Set Prs = dbm.GetRs(Rst)
Set SelectJobs = dbm.RsToCollection(Prs)
End Function
'初始化(構造函數) 自定義本類的實例時觸發
Private Sub Class_Initialize()
Set dbm = New clsDBManager '數據庫管理類
Dim dbc As clsDBConfig
Set dbc = New clsDBConfig '數據庫配置類
dbc.DBType = SqlServer '數據類型
dbc.DBName = "pubs" '數據庫名稱
dbc.LoginType = Sql '登陸類型
dbc.LoginName = "sa" '登陸名
dbc.LoginPwd = "ok" '登陸密碼
dbc.HostName = "." '服務器名
dbm.ConToDB dbc 'dbm調用管理類函數ConToDB來連接數據庫 參數為dbc
End Sub
'析構函數 當本類的實例的所有引用從內存中刪除,或當對象的最后一個引用失去范圍時就會觸發此事件
Private Sub Class_Terminate()
dbm.DisCon '連接數據庫關閉
Set dbm = Nothing '釋放內存
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -