Article ID: 190411 - Last Review: March 2, 2005 - Revision: 2.4 How To Bind a DataReport To an ADO Recordset at Run TimeThis article was previously published under Q190411 SUMMARY
The DataReport is a powerful tool and it's easy to build complex reports by
dragging and dropping fields out of the DataEnvironment window. However,
there are times when you may want to bind the DataReport directly to an
ActiveX Data Objects (ADO) recordset rather than to the DataEnvironment.
For example, you may have built a hierarchical query with ADO, or you may
have an n-tier application that receives a recordset from a business
object.
This article helps you understand how to bind a DataReport directly to an ADO recordset. MORE INFORMATION
First, build a hierarchical query with the DataEnvironment. Next, create a
simple DataReport that is based on your query and bound to the
DataEnvironment.
Use the DataEnvironment to connect to the Northwind database (NWind.mdb) that is included with Visual Basic by following these steps:
RESULT: Run the project, and you should see the report with the customer and order information. The DataReport uses the DataSource and DataMember properties to find the top-level command on which the report is based. For example, if you have a hierarchical query in the DataEnvironment containing Customers, Orders, and Order Details information but you only want to show the Orders and Order Details information, then you should set the DataSource property to be the DataEnvironment, and the DataMember property to be the Orders command. Each field on the DataReport has two properties that allow the DataEnvironment to determine what information to show on the report:
For example, the CustomerID field is in both the Customers and the Orders table. If you want to show the CustomerID field with the rest of the customer information, set DataMember to Customers. If you want to show the CustomerID with the rest of the Order information, set DataMember to Orders. When you bind directly to a recordset object as shown in step 21, the DataSource property of the DataReport should be set to the recordset object and the DataMember property should be set to an empty string. For the fields on the report, the DataMember property of the top-level recordset information (customer information in this case) should be set to an empty string. For information other than that which is in the top-level recordset (Order information in this case), the DataMember property of the report TextBoxes should be set to the name of the command (Orders in this case). | Article Translations
|
Back to the top
