Share via


Visual Basic Concepts

Using a Data Environment with Your Application

At , the Data Environment creates ADO Command and Connection objects for each Command and Connection object defined in the Data Environment designer. If the Command object is marked as Recordset Returning (on the Advanced tab of the Command Properties dialog box), then an ADO Recordset object is also created. The ADO Command object is added as a method from the Data Environment run-time object, and the ADO Connection and Recordset objects are added as properties.

There are two ways to use a Data Environment in your application at run time:

  • As a direct data source for data binding to controls on a .

  • To programmatically create an instance of the Data Environment and execute its Command objects.

In addition, the run-time Data Environment contains Commands, Connections, and Recordsets collections. These 1-based collections offer another means of programmatically accessing the ADO objects, allowing you to enumerate the various objects.

Note   The index for the first member of the collection starts at the number one in 1-based collections. ADO objects are 0-based, thus the Fields and Parameters collections are 0-based, and thus, start at zero.

In the Data Environment, the names of ADO Recordset objects are prefaced with "rs" to distinguish them from their corresponding Command objects. For example, a Command object named Customers creates a Recordset object named rsCustomers. By default, Recordset objects are closed. When the Recordset object's corresponding Command method executes, the Recordset object opens. For example, executing the Customers method opens the Recordset object of "rsCustomers." In addition, you can open a Recordset object directly using the ADO Open method. Using this method, you can manipulate a Recordset object before it is opened.