Realization of Master/detail Relation function of database report under C + + Builder

Source: Internet
Author: User
Tags one table

The master-slave composite structure (Master/detail) is based on "one-to-many" relationships, providing detailed information in a database table that accesses related records through foreign keywords from another database table. Based on the master-slave composite structure, we can browse the data in one table and give all the record information related to the record in another table. Borland C++builder provides a ttable and tquery type of database control that can easily implement the Master/detail relationship of database tables, In this paper, we take the example database Bcdemos in BCB as an example to illustrate how to implement the master-slave composite structure relationship of the data table by different methods, Take the data browsing function as an example: When browsing the Master Datasheet customer.db (Customer information) record, display the details of all records associated with it from the datasheet orders.db (Customer order information).

The basic properties related to the Ttable control are described below: DatabaseName: Set the database alias or database directory path to open; TableName: Set the file name of the database table you want to associate open, Active: The database table file opens automatically when set to true. Otherwise, you need to open the data table in your program with code. Tquery control's basic properties: DatabaseName: Sets the database alias or database directory path to open; The sql:tstring type, the SQL data query statement to execute, can be directly in the object viewer Inspector) Double hit Open SQL property for editing, Active: When set to true automatically open query database table file, otherwise you need to use code to open the query datasheet in the program. The properties associated with M/D will be explained in conjunction with the example below.

One, Ttable Control Association master, Implementation master/detail Relationship report from table

The simplest way to implement a master/detail relationship is to associate two Ttable controls with the primary table and from the table, respectively. Named Tablemaster and Tabledetail respectively, set tablemaster databasename as Bcdemos, TableName is customer.db; the databasename for Tablemaster is bcdemos,tablename for orders.db. So you can correlate the master and subordinate data tables separately.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.