Our Products
Classes
BMP
Crypto
CSVStrings
DataLogger
Dates
DebugRecorder
FileNameSet
FileSender
RDOConnectMaster
ReportAids
Sheller
StringSet
WEBUtilities
Modules
DAOLib
Globals
Registry
Programs
Batcher
HTMLGen
KillTime
TimedMessage
|
RDOConnectMaster provides automatic/intelligent connection control to your Access or SQL Server databases. This means you can use the same code to interface with either database server. We take advantage of this to shorten our development activities, by developing with Access and deploying with SQL Server.
The class automatically ensures that a database connection is made just once for any given database session. This means you can code each database function as a stand-alone unit that opens a connection, does its work, and then closes the connection (encapsulation at its finest). Then, when all your functions are used together, multiple (quite wasteful, excess) connections are avoided.
What does this mean for your applications? When we started using RDOConnectMaster, our network access overhead dropped by over 50%.
The class builds its own DSN-less connect string to your database. This avoids costly Registry searches on the client machine.
For this specific implementation, we chose to use lean and mean Remote Data Objects; resulting in the most efficient possible access to the database. But the methods used will work equally well for ADO or DAO with minor changes to the connect string and procedures called.
To see sample use of RDOConnectMaster and its full interface definition, scroll down. |
|
This is a small piece of code that uses RDOConnectMaster to establish a ReadOnly connection to the SignatureServer and
then creates a recordset via a dynamically created SQL statement. So far this looks like the normal rdo stuff.
The trick comes when the {other processing} segment calls upon other subroutines that are doing the same kinds
of connections to the same database. If you're minimizing repeated code, this is going to be a normal situation.
By using RDOConnectMaster, only ONE connection (the first one) will actually
be made; not TWO or THREE or more! Likewise, only the last encountered call to
dbClose will actually close the connection.
Not using rdo? No problem! Just copy and
customize RDOConnectionMaster to do the same same trick with DOA, ADO, or whatever. |
dim oSigDb as RDOConnectMaster 'declare our object
dim Sigdb as rdoConnection 'declare connection object
Set oSigDb = New RDOConnectMaster 'initialize our object
oSigDb.Srvr = lSignatureServer 'set database server name
oSigDb.DataBaseName = lSignatureDatabase 'set database name
oSigDb.UID = lSignatureUser 'provide a user name
oSigDb.PWD = SigPassword 'provide a password
If oSigDb.dbOpen(OpenModes.ReadOnly, Sigdb) Then 'open connection
Sql = "SELECT Unit,EmpNo,EmpName,UserId,DollarLimit,Img FROM " + _
"Signatures WHERE ... "
Set rs = Sigdb.OpenResultset(Sql, rdOpenKeyset, rdConcurRowVer)
'get the recordset
.
.{other processing}
.
Call oSigDb.dbClose(Sigdb) 'close the connection
Else 'problem with the open
lstatus = FormatError(SubName, "Could not open "+oSigDb.DataBaseName)
End If
|
| Here is the interface definition for the RDOConnectionMaster Class. dbOpen supports both SQL Server
and Access databases. If the connection is for an Access database, set DataBaseName to the fully qualified
name of the database file; otherwise set it to the SQL Server database name and set Srvr to the name of the
server. |
Public Enum OpenMode
ReadOnly = True 'dbOpen argument, connection is read-only
ReadWrite = False 'dbOpen argument, connection is read/write
End Enum
Public Property Get Connect() As String 'Return Connect string
Public Property Get DataBaseName() As String 'Return name of database
Public Property Let DataBaseName(ByVal NewDataBaseName As String)
' Set database name
Public Sub dbClose(db As rdoConnection) 'Close connection db
Public Function dbOpen(rw As OpenMode, db As rdoConnection) As Boolean
' open connection db according to OpenMode
Public Property Get OpenDepth() As Integer
' Return nesting level of opens
Public Property Get OpenTime() As Date
' Return time connection was opened
Public Property Get PWD() As String 'Return database password
Public Property Let PWD(ByVal NewPWD As String) 'Set database password
Public Property Get Srvr() As String
' Return name of database server
Public Property Let Srvr(ByVal NewSrvr As String)
' Set database server name
Public Property Get Time() As Long
' Return how long connection was open
Public Property Get UID() As String 'Return user ID
Public Property Let UID(ByVal NewUID As String) 'Set user ID
Public Property Get WSID() As String 'Return work station ID
Public Property Let WSID(ByVal NewWSID As String) 'Set workstation Id
Public Property Get Error() As String
' Get text of last error. Use clears text
|
|