Hi Everyone,
I am using an ADO Connection to connect to an access database from excel. The connection is used to retreive a tracking number from the database and then update it to show the tracking number has been used.
Am currently investigating seesion pooling to decrease the wireless network load. There are multiple users using this code over our wirless network.
Can pooling be implemented for multiple users with the same connection?
Code so far:
Code
Option Explicit
Dim adoCon As ADODB.Connection
Sub OpenConnection()
Dim sCon As String
'Open connection
sCon = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\\ALLAN\Databases\TrackIDs.mdb"
Set adoCon = New ADODB.Connection
adoCon.Open sCon
End Sub
Sub CloseConnection()
adoCon.Close
Set adoCon = Nothing
End Sub
Sub TestConnection()
debug.print GetTrackNo
End Sub
Function GetTrackNo()
Dim adoRCS As ADODB.Recordset
Dim lTrack As Long
Dim i As Long
'Set New Recordset
Set adoRCS = New ADODB.Recordset
With adoRCS
'Open Record Set
.Open "SELECT * FROM Table1", adoCon, adOpenStatic, adLockOptimistic
'Get New Tracking No
lTrack = .RecordCount + 1
'Add New Tracking
.AddNew
.Fields("ID").Value = lTrack
'Update Tracking Databas
.Update
'Close Record Set
.Close
End With
'Set All Variables To Nothing And Close Connection
Set adoRCS = Nothing
GetTrackNo = lTrack - 1
End Function
Display More
The open and close connection subs are run on wrkbook open and close respectively.