TMyQuery : save / load data?

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
starhu
Posts: 34
Joined: Thu 13 Aug 2009 12:13

TMyQuery : save / load data?

Post by starhu » Sun 23 Dec 2018 20:12

Hello,

I need to save the rows of a TMyQuery and load the save file back at user demand (just like with TVirtualTable).

How can I do that?

Thank you very much!

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: TMyQuery : save / load data?

Post by ViktorV » Thu 27 Dec 2018 12:23

If you want to save a query execution result, and then open it - you can do it using the VirtualTable component.
You can use methods SaveToFile and LoadFromFile for data loading and saving in VirtualTable on all the supported platforms. Data will be saved as binaries. You can assign a TMyQuery to a TVirtualTable. You can read about to fill TVirtualTable with data from another TDataSet component in the VirtualTable help: https://devart.com/virtualdac/docs/inde ... bject).htm For example:

Code: Select all

VirtualTable.Assign(MyQuery);
If you mean something else, please write to us in more detail.

starhu
Posts: 34
Joined: Thu 13 Aug 2009 12:13

Re: TMyQuery : save / load data?

Post by starhu » Thu 27 Dec 2018 12:53

Hello,

Thank you for the answer. I will describe the situation so as you would understand my problem:

- There is a grid connected to a TMyQuery
- The TMyQuery is connected to a temporary table
- The user adds new records, and fills the different field values

He should be able to save all the data in database (under a certain name), close the program, open it a few days later and load the selected save back into the grid (TMyQuery).

If I use your solution, and Assign to a TVirtualTable, I can save the data indeed.
But is there an easy way to load data from TVirtualTable back to TMyQuery? (without iterating all the records)

Thank you very much!

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: TMyQuery : save / load data?

Post by ViktorV » Thu 27 Dec 2018 13:41

The similar question has already been discussed on our forum. Follow the link viewtopic.php?f=6&t=26963 for details.
If it doesn't help to solve the issue, please compose a full sample demonstrating the issue including the script for creating and filling in the database objects and send it to us via form e-support: https://devart.com/company/contactform.html

starhu
Posts: 34
Joined: Thu 13 Aug 2009 12:13

Re: TMyQuery : save / load data?

Post by starhu » Thu 27 Dec 2018 14:58

Hello Victor,

Thank you for your reply. The link you gave me linked to a "Access violation on Win32 target" topic ...

Thank you

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: TMyQuery : save / load data?

Post by ViktorV » Thu 27 Dec 2018 15:12

We changed the link to the correct one.

Post Reply