Data ADO enables you to answer questions that can be expressed as a Recordset. For example, suppose you want a list of company customers, and you have a database that contains a table named Customers. When a query command is issued against a table, ADO returns the Recordset, in which each row represents a customer, and each row's column has a data type that can contain the customer's name, address, customer ID, and so on.
Data configuration enables you to answer questions that can be expressed by the formed Recordset. The data configuration defines the columns of the forming Recordset, the relationship between the columns representing the entries, and the way data is filled into the recordset.
The columns of the formed Recordset can contain data from the data provider (such as SQL Server), a reference to another recordset, a computed value for a row of the recordset, and a value for manipulating the columns of the entire recordset. Or it could be a new, fictional, empty column.
When retrieving the value of a column containing a reference to another Recordset, ADO automatically returns the actual Recordset represented by the reference. A recordset that contains another recordset is called a hierarchical Recordset or a hierarchical cursor.
For example, suppose you want to get a list of all orders issued by each customer of the company. You can emit a data-configuration command on a database table that contains the name Customers and orders. As in the previous example, ADO returns the customer record Recordset. However, each row has additional columns that reference the Recordset that contains all the customer orders.
Improve the shape to get a list of sales totals by state. The address column in the Customers table contains the states of each customer, and the quantity column of the Orders table contains the number of each order. Emits a different data-configuration command, ADO returns the Recordset, which contains a row for each state (where each row contains the column that identifies the state), the total sales totals for all orders in the state, and a reference to the Recordset that lists all the customers for that state. Accessing the customer Recordset will find that, like the previous example, each customer row contains a reference to the Recordset that contains all of the customer orders.
The shape command syntax enables you to create a formed Recordset programmatically. You can then access the Recordset's components through programmatic or appropriate visual controls.
Overview of data configuration
ADO 2.0 introduces data-configuration features, hierarchical recordsets, and Shape command syntax.
ADO 2.1 Launches the refactoring, grandchild totals, and parameterized commands by inserting the COMPUTE command.
Data configuration
Data configuration enables you to define the columns of the formed Recordset, the relationships between the entries represented by the columns, and the way data is filled into the recordset.
The columns of the formed Recordset can contain data, a reference to another recordset, a computed value for one row of the recordset, a value that is manipulated on the entire recordset's columns, or it can be a newly fictitious empty column.
When retrieving the value of a column containing a reference to another Recordset, ADO automatically returns the actual Recordset represented by the reference. A recordset that contains another recordset is called a "hierarchical Recordset." The hierarchical recordsets shows the parent-child relationship where "parent" is the contained recordset and "Child" is the contained recordset. References to a Recordset are actually references to a subset of pairs (that is, "subset"). A single parent can contain multiple child recordsets.
ADO 2.0 also introduces a new shape command syntax that enables you to programmatically create a formed Recordset object. The Shape command can be emitted like any other ADO command text.
Using the Shape command syntax, you can create a hierarchical Recordset object in two ways. The first is to append the child Recordset to the parent Recordset, in general, the parent and child must have at least one column: The value of the column in the parent's row is the same as the value of the column in all rows of the child.
The second is to generate the parent Recordset from the child Recordset. You must have a subset column in the parent that references the child Recordset. Other parent columns are created by the total operation of the child column, by the expression of the Recordset row, by specifying the grouped column with the by keyword, or by appending a new empty column.
You can nest a hierarchical Recordset object to any depth you want (that is, to create a child Recordset object for a child Recordset object, so continue).
The recordset component of a formed recordset can be accessed through a program or corresponding visual control.
Microsoft provides a visualizer that can generate a Shape command (see Visual Basic topics, Data Environment Designer), and another visualizer that can display a rating cursor (see Visual Basic topics, "Using Microsoft Hier Archical FlexGrid Control ").
Refactoring form
The Recordset created by the clause of the Shape command can be assigned to "alias" (generally using the AS keyword). In ADO 2.1, the alias of a formed Recordset can be referenced in a completely different command. That is, a new Shape command can be issued to change (that is, refactoring) a previously-framed Recordset. To support this feature, ADO provides a new Recordset object Name property.
Restricted to not being able to append columns to an existing recordset, or to refactor a parameterized Recordset or Recordset object in any clause inserted into a COMPUTE, or to execute on any recordset other than the recordset that is being framed Total operation.
Total grandchildren
A subset of columns created with the Shape command's clause can get a "subset-alias name" (generally using the AS keyword). You can use to identify the full name of the child that contains the column, and identify any columns of the formed Recordset in the child set. For example, if a parent-child set CHAP1 contains a subset of CHAP2 that have a number of AMT, the full name will be Chap1.chap2.amt. The full name can then be used as a parameter in the aggregate function (sum, AVG, MAX, MIN, COUNT, STDEV, or any).
Using parameterized commands that insert the COMPUTE command
A typical parameterized Shape APPEND command contains a clause that creates a parent Recordset through a query command, and a parameterized query command that contains a parameter placeholder: A question mark? command) to create another clause for the child Recordset. The resulting formed Recordset has two layers, with the father on top and the child occupying the lower level.
The clause that creates the child Recordset can now be any number of nested shapes COMPUTE commands that contain parameterized queries in the deepest nested commands. The resulting formed Recordset has multiple layers, the parent occupies the topmost layer, the child occupies the lowest level, and any number of recordsets generated by the shape COMPUTE command occupies the inserted layer.
The typical use of this feature is to invoke the grouping function of the aggregate function and shape COMPUTE commands, creating an Insert Recordset object with profiling information about the child Recordset. In summary, because this is a parameterized Shape command, a new child Recordset can be retrieved whenever a subset of the parent is accessed. Because the insertion layer originates from the child, they are also recalculated