Visual Basic Concepts
It is not necessary to create a connection using an rdoEnvironment object, because you can simply declare a free-standing rdoConnection object using the Dim As New syntax. For example, the following code creates a stand-alone rdoConnection object named MyCn.
Dim MyCn As New rdoConnection
By using the User Connection Designer, you can also create your own Visual Basic class that inherits from the rdoConnection object to extend the object with functionality of your own design.
Once you create a stand-alone connection, you can set the Connect property of your new rdoConnection object to address a specific server, cursor driver, and other properties as described below. Once these properties are initialized, you can use the EstablishConnection method to connect with the specified server.
For example, to create a stand-alone rdoConnection object and establish a connection to a server specified by the CustomerDB DSN, you can use the following code:
Dim MyCn As New rdoConnection
With MyCn
.Connect = "DSN=CustomerDB;DATABASE=MAILING;" _
& "UID=;PWD=;"
.CursorDriver = rdUseNone
.LoginTimeout = 5
.EstablishConnection (rdDriverNoPrompt)
End With
If you want to associate your new stand-alone rdoConnection
with a specific rdoEnvironment
, you must use the Add
method to add it to the rdoConnections
collection associated with a selected rdoEnvironment
object. For example, the following code adds the MyCn
connection to the default rdoEnvironment
object:
rdoEnvironments(0).rdoConnections.Add MyCn
You can remove members from the rdoEnvironments
collection by using the Remove
method.
For More Information See "EstablishConnection Method" in the Language Reference" for details on using stand-alone connections.