Visual Basic Concepts

Creating an rdoEnvironment Object

In most cases, your application need not create an additional rdoEnvironment object — the default rdoEnvironments(0) should suffice for most operations. However, if your application expects to support more than one transaction scope, or separate user name and password contexts, you should use the rdoCreateEnvironment method to create a new rdoEnvironment object with specific user name and password values. This method accepts a unique name, a user name, and password. If the name you choose matches the name of an existing member of the rdoEnvironments collection, a trappable error results.

The default rdoEnvironments(0) is created automatically when the RemoteData control is initialized, or when the first RDO object is referenced in code. The Name property of rdoEnvironments(0) is "Default_Environment." The user name and password for rdoEnvironments(0) are both zero-length strings ("").

Newly created rdoEnvironment objects are automatically appended to the rdoEnvironments collection if you provide a unique name. You can also use a zero-length string for the name argument of the rdoCreateEnvironment method. In this case, the new rdoEnvironment is not appended to the rdoEnvironments collection.

Cached Logon Information

The user name and password information from the rdoEnvironment is used to establish the connection if these values are not supplied in the connect argument of the OpenConnection method, or in the Connect property of the RemoteData control.

For example, the default user name (Fred) and password (Blond) can be used to establish a connection in the En environment:

Dim En As rdoEnvironment
Set En = rdoCreateEnvironment("", "Fred", "Blond")

An rdoEnvironment object logically corresponds to an ODBC environment. You can refer to an rdoEnvironment object using the ODBC API functions, by referencing an rdoEnvironment object's hEnv property. However, because ODBC implementations only allow one environment handle per application, the actual lifetime of the ODBC environment handle is tied to the lifetime of the rdoEngine.