Recent

Author Topic: SOLVED: Passing results from a Query to a new one  (Read 518 times)

SaraT

  • Jr. Member
  • **
  • Posts: 86
  • A little student
SOLVED: Passing results from a Query to a new one
« on: February 07, 2020, 06:07:37 am »
Hi guys :)

I have two component:
1- Query1 (created in designtime)
2- Query2 (created in runtime)

Is there a way to get the results of Query1 and pass the results of Query1 to Query2 component?

The case is that I don't want to use Query2.SQL.Text

I have tried with the below code but I got a "Access violation" error.
Code: Pascal  [Select][+][-]
  1. Query2.DataSource.DataSet := Query1.DataSource.DataSet;


Any idea? Many thanks.
« Last Edit: February 09, 2020, 03:36:37 am by SaraT »

HeavyUser

  • Sr. Member
  • ****
  • Posts: 310
Re: Passing results from a Query to a new one
« Reply #1 on: February 07, 2020, 07:30:59 am »
depends on the destination query but in short you need to
1) duplicate the source query internal schema (fieldDefs, and fields collections)
2) call query1.createdataset to create the internal buffers.
3) write a loop to copy each row of the source query field by field to an appended row on the destination query.

mangakissa

  • Hero Member
  • *****
  • Posts: 1094
Re: Passing results from a Query to a new one
« Reply #2 on: February 07, 2020, 08:37:43 am »
use TBufdataset.
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

rvk

  • Hero Member
  • *****
  • Posts: 4324
Re: Passing results from a Query to a new one
« Reply #3 on: February 07, 2020, 08:59:14 am »
Is there a way to get the results of Query1 and pass the results of Query1 to Query2 component?
The case is that I don't want to use Query2.SQL.Text
Maybe you can also explain WHY you don't want to use SQL.Text.
Maybe that reason is easilly (and better) fixed than your imagined solution.

 

TinyPortal © 2005-2018