-
Notifications
You must be signed in to change notification settings - Fork 2
/
clsDBInstance.cls
34 lines (26 loc) · 1.09 KB
/
clsDBInstance.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Option Explicit
Private objSharedClass As clsDatabase
Public Function GetNewDatabase(Optional ByVal DBName As String) As clsDatabase
Set GetNewDatabase = CreateDatabase(DBName)
End Function
Public Function GetSharedDatabase(Optional ByVal DBName As String) As clsDatabase
If objSharedClass Is Nothing Then
Set objSharedClass = CreateDatabase(DBName)
End If
Set GetSharedDatabase = objSharedClass
End Function
Public Function CloseSharedDatabase() As Boolean
CloseSharedDatabase = objSharedClass.CloseDatabase
Set objSharedClass = Nothing
End Function
Private Function CreateDatabase(Optional ByVal Name As String) As clsDatabase
Dim objDatabase As clsDatabase
Dim objDBCredentials As clsDBCredentials
Set objDBCredentials = New clsDBCredentials
Set objDatabase = New clsDatabase
objDBCredentials.SetServer = "WORK-PC"
objDBCredentials.SetDBName = "DataAccessDemo"
objDBCredentials.SetTrustedSecurity = True
objDatabase.OpenDatabase objDBCredentials
Set CreateDatabase = objDatabase
End Function