ADO - ClientDataSet - Master/Detail
- From: "Davide Pasqualini" <bytetech@xxxxxxxxx>
- Date: Fri, 22 Sep 2006 12:03:12 +0200
Hi,
I'm trying to use ADO and ClientDataSet with Delphi 6 Prof. and MSSQL.
My DB sample tables are declared as follow:
CREATE TABLE MASTER (
IDMASTER integer identity(1, 1) NOT NULL ,
DESC varchar(40),
CONSTRAINT PKMASTER PRIMARY KEY (IDMASTER)
)
CREATE TABLE DETAIL (
IDMASTER integer NOT NULL ,
IDDETAIL integer identity(1, 1) NOT NULL ,
DESC varchar(40) ,
CONSTRAINT PKDETAIL PRIMARY KEY (IDMASTER, IDDETAIL)
)
In Delphi DB components are linked in this way:
MASTER: ADOQuery1 --- DataSetProvider 1--- ClientDataSet1 ---
DataSource1 --- DBGRID1
DETAIL: ADOQuery2 --- DataSetProvider2 --- ClientDataSet2 ---
DataSource2 --- DBGRID2
The master/detail relationship is kept at the TADOQuery level.
The detail ClientDataSet is linked to the master by DataSource and the query
parameter.
The open statements are directed at the ClientDataSet (first Master and then
Detail) .
When I call Apply updates (first Master and then Detail) I get an error
because IDMASTER field in DETAIL table is null (and I don't see it in the
dbgrid).
So, my question is: How new detail records can get the master value ?
Thanks in advance.
.
- Follow-Ups:
- Re: ADO - ClientDataSet - Master/Detail
- From: Bill Todd
- Re: ADO - ClientDataSet - Master/Detail
- Prev by Date: Re: TADOQuery Error Handling
- Next by Date: Re: Delphi 6 - ADO - MS SQL Server
- Previous by thread: TADOQuery Error Handling
- Next by thread: Re: ADO - ClientDataSet - Master/Detail
- Index(es):