PDA

Ver la Versión Completa : Relacionar maestro con detalle


Eolo
25-06-2007, 18:08:48
Hola a todos, tengo un servidor remoto que crea un DataSetProvider con un TADODataSet con detalles.

Como hago en los detalles para indicar cual es el TField que hace la relacion con el maestro, ya que lo asigne en la propiedad IndexFieldNames del detalle pero cuando veo el DataSet en el cliente esta propiedad esta vacia?

Desde ya muchas gracias

:confused:

NestorN
17-10-2007, 03:36:33
Hola, nunca trabaje con el provider, pero para usar un maestro detalle supongo que debe ser mas o menos iguales casi todos.
Mira en el dataset de detalle definí el index field name, y el masterfields. Asigna el datasourse del maestro y deberia arrancarte.

Suerte

karlaoax
17-10-2007, 16:42:18
Mira no soy del area, pero leyendo mucho una vez encontre lo siguiente, y funciona perfectamente :cool:, solo espero que andes bien con tu ingles:


How To Create a Master-Detail Form Using TTable Component

The steps in this How To show how to build a form containing two tables: a master table and a detail table, linked one-to-many.

Difficulty Level: average Time Required: 10 minutes
Here's How:
1.Start Delphi and select File | New Application...

2.Select Data Access page on the Component palette. Place two TTable components on a form. Place two TDataSource components on a form.

3.Select Data Controls page on the Component palette. Place two TDbGrid components on a form.

4.Set the DatabaseName of the TTable components (Table1 and Table2) to the name of the database to access. Select DBDemos.

5.Set the TableName property to the name of the table in the database. Select customer.db for the master table: Table1.

6.Do the same with the child table. Select orders.db for the Table2.
7.Select the first TDataSource (DataSource1) component and set DataSet property to the name of the table component, that is: Table1.

8.Do the same with the second TDataSource (DataSource2) component and set DataSet property to the name of the table component, that is: Table2.

9.Select the first TDbGrid (DBGrid1) component and set the DataSource property to the name of the data source component, i.e. DataSource1. The same for, that is, TDbGrid2.DataSource:=DataSource2.

10.Set the MasterSource property of the Table2 component to the DataSource1.

11.Set the IndexFieldName property of the Table2 component to the CustNo.

12.Click the ellipsis button next to the MasterFields property of the Table2. This will invoke the Field Link Designer.

13.In the Detail Fields list the select CustNo, in the MasterFields list select CustNo. Click Add. Click Ok.

14.Set the Active property of both table components to True.

15.Browse through the records.


Tips:
The most important thing in master-detail relationship is the link between the tables. For each record in the master table, the form displays all corresponding records in the detail table.
Important detail table properties are: IndexFieldNames, MasterFields and MasterSource. For more info look in Delphi Help files.


Los pasos mas importantes son apartir del No. 10.

Espero te sirva.
Atte.
Karla :p