ParamByName in Master/Detail
Posted: 27.11.2017, 11:16
Hi, I have 2 TQuery components conected with TQuery2.Datasource property.
TQuery1, MasterSQL:
SELECT id, field1, field2
FROM master
TQuery2, DetailSQL:
SELECT field1, master_id
FROM detail
WHERE master_id = :id
Question: is TQuery2.ParamByName('id') automaticly set, when using this type of connection?
Purpouse:
I connect TQuery2 with Datasource property when records should dynamicly change or with ParamByName when other type required (usually some modal form).
So when you call:
Is this how Zeos works or am I something missing?
TQuery1, MasterSQL:
SELECT id, field1, field2
FROM master
TQuery2, DetailSQL:
SELECT field1, master_id
FROM detail
WHERE master_id = :id
Question: is TQuery2.ParamByName('id') automaticly set, when using this type of connection?
Purpouse:
I connect TQuery2 with Datasource property when records should dynamicly change or with ParamByName when other type required (usually some modal form).
So when you call:
Code: Select all
procedure TDatamodule.qryQuery2BeforePost(DataSet: TDataSet);
begin
// this part should not be needed
if Assigned(qryQuery2.DataSource) then
fldQuery2ID.AsString := qryQuery2.DataSource.DataSet.FieldByName('id').AsString
// this should be enought for both versions
else
fldQuery2ID.AsString := qryQuery2.ParamByName('id').AsString;
end;