2 TADOQUERY主表和明细表过滤器插入
我如何使用 2 个 Tadoquery 并像 Tadoquery(主)Tadotable(详细)一样工作!
var tempvar : Variant;
begin
Edit1.text:=Ano.value;
Begin
with Ano_planeamento do //Laço de consulta por codigo
Begin
Close;
SQL.Clear;
SQL.Add('SELECT * from planeamento_ano');
SQL.Add('Where ano LIKE ''%'+Edit1.text+'%''');
Open;
end;
end;
tempvar := Ano_planeamento.fieldbyname('ano').value;
planeamento.close;
if tempvar <> null then
begin
planeamento.SQL.Clear;
planeamento.SQL.add('SELECT * FROM planeamento');
planeamento.SQL.add(' WHERE ano = ');
planeamento.SQL.add('''' + tempvar + '''');
// here i nead to filter by ....
planeamento.open;
How can i work with 2 Tadoquery and work like a Tadoquery (master) Tadotable(detail) !!
var tempvar : Variant;
begin
Edit1.text:=Ano.value;
Begin
with Ano_planeamento do //Laço de consulta por codigo
Begin
Close;
SQL.Clear;
SQL.Add('SELECT * from planeamento_ano');
SQL.Add('Where ano LIKE ''%'+Edit1.text+'%''');
Open;
end;
end;
tempvar := Ano_planeamento.fieldbyname('ano').value;
planeamento.close;
if tempvar <> null then
begin
planeamento.SQL.Clear;
planeamento.SQL.add('SELECT * FROM planeamento');
planeamento.SQL.add(' WHERE ano = ');
planeamento.SQL.add('''' + tempvar + '''');
// here i nead to filter by ....
planeamento.open;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果在详细信息中将数据源设置为主数据库,那么您可以尝试在详细信息中使用与主数据库中的字段匹配的参数。因此,如果在 master 中您有以下内容:
从表中选择字段1、字段2、字段3
然后在细节上你有:
从详细信息 WHERE some_field=:field1 中选择 d_field1、d_field2、d_field3
这样参数'field1'与从master返回的字段(field1)具有相同的名称。
If in the detail you set the datasource to the master then you can try using parameters in the detial that match a field in the master. So if in the master you have the following:
SELECT field1, field2, field3 FROM table
Then in the detail you have:
SELECT d_field1, d_field2, d_field3 FROM detail WHERE some_field=:field1
So that the parameter 'field1' has the same name of a field (field1) returned from the master.
从古代历史(即五年多前)来看,使用 VCL 数据集自动处理主/细节的方式是通过在关联的 TDatasource 组件上设置属性。请参阅此处的示例: http://delphi.about.com/library/howto/ htdbmasterdetail.htm
否则,只需动态更改详细数据集的 SQL 中的 WHERE 子句,或在详细数据集上设置 Filter 属性:http://docwiki.embarcadero.com/VCL/en/DB.TDataSet.Filter
Speaking from ancient history (i.e, over five years ago) the way master/detail was handled automatically with VCL datasets was by setting properties on associated TDatasource components. See here for an example: http://delphi.about.com/library/howto/htdbmasterdetail.htm
Otherwise just dynamically alter the WHERE clause in the SQL for the detail dataset, or set the Filter property on the detail dataset: http://docwiki.embarcadero.com/VCL/en/DB.TDataSet.Filter