Drew Wutka
DWUTKA at Marlow.com
Tue Jun 1 15:46:52 CDT 2010
Ok, here's an example: (this would be for an .mdb, but the premise is
the same)
Class: DatabaseConnection
Public Enum ISFEDatabaseTypes
idtNetwork = 1
idtDevelopment = 2
idtLocal = 3
End Enum
Dim strNetworkPath as string
Dim intDatabasetType as ISFEDatabaseTypes
Dim withevents DBTimer as Timer
Dim intCurrentConnections as Long
Dim blISFEConnected AS Boolean
Dim ISFEBackend as ADODB.Connection
Private Sub Class_Initialize()
ISFEDatabaseType = idtNetwork
Set DBTimer = frmStartup.tmrTempDB
blISFEConnected = False
intCurrentConnections = 0
End Sub
Property Let ISFEDatabaseType(intEnter As ISFEDatabaseTypes)
intDatabaseType = intEnter
Select Case intDatabaseType
Case idtNetwork
strNetworkPath = "\\NAS\Data\AccessDB\ISFE\"
Case idtDevelopment
strNetworkPath ="\\NAS\Data\AccessDB\ISFEDev\"
Case idtLocal
strNetworkPath = App.Path & "\"
End Select
End Property
Property Get ISFEDatabaseTypeString() as string
Select Case intDatabaseType
Case 1
ISFEDatabaseTypeString="Network"
Case 2
ISFEDatabaseTypeString="Development"
Case 3
ISFEDatabaseTypeString="Local"
End Property
Property Get ISFEDatabaseType() As ISFEDatabaseTypes
ISFEDatabaseType = intDatabaseType
End Property
Friend Function ReleaseISFEDBConnection()
intCurrentConnections = intCurrentConnections - 1
If intCurrentConnections <= 0 Then
DBTimer.Interval = 15000
DBTimer.Enabled = True
End If
End Function
Friend Function ISFEDBConnect(ByRef cnn As ADODB.Connection)
If Not blISFEConnected Then DBConnect
Set cnn = ISFEBackEndDB
intCurrentConnections = intCurrentConnections + 1
DBTimer.Enabled = False
End Function
Private Function DBConnect()
Set ISFEBackEndDB = New ADODB.Connection
ISFEBackEndDB.Provider = "Microsoft.Jet.OLEDB.4.0"
ISFEBackEndDB.Open strNetworkPath & "ISFEBackEnd.mdb"
blISFEConnected = True
ISFEBackEndDB.Open
End Function
Friend Function ReleaseISFEDBConnection()
intCurrentConnections = intCurrentConnections - 1
If intCurrentConnections <= 0 Then
DBTimer.Interval = 15000
DBTimer.Enabled = True
End If
End Function
Private Sub DBTimer_Timer()
ISFEBackEndDB.Close
Set ISFEBackEndDB = Nothing
blISFEConnected = False
DBTimer.Enabled = False
End Sub
I'll post it's usage in another post...
Drew
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Brad Marks
Sent: Tuesday, June 01, 2010 1:22 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Friday's Puzzler - Table
Def"Connection"Info(DatabaseName)
Drew,
I would like to see the class for the connection object that enables
switching the data source.
Thanks,
Brad
The information contained in this transmission is intended only for the person or entity
to which it is addressed and may contain II-VI Proprietary and/or II-VI Business
Sensitive material. If you are not the intended recipient, please contact the sender
immediately and destroy the material in its entirety, whether electronic or hard copy.
You are notified that any review, retransmission, copying, disclosure, dissemination,
or other use of, or taking of any action in reliance upon this information by persons
or entities other than the intended recipient is prohibited.