How to copy a firedac dataset from FDMemTable to FDTable (SQLite connected) [Edit] #2

I have TDBGrids connected to FDTable1 via a Datasource component.
FDTable1 is not using CachedUpdates.

When I ran the code, looking at the TDBGrid, the data is copied.
But when I open the SQLite database containing FDTable1, the table however is empty!

// Copy query results to a FDMemTable. It works OK!
  FDQuery1.SQL.Text:= 'select userno, loginid from user';
  FDQuery1.Open;
  FDQuery1.FetchAll;
  FDMemTable1.Active:= False;
  FDMemTable1.Data:= FDQuery1.Data;
  FDMemTable1.Active:= True;

// Copy from FDMemTable to FDTable.
  FDConnection1.Offline;
  FDTable1.Active:= False;
  FDTable1.Data:= FDMemTable1.Data;
  FDConnection1.Online;
  FDTable1.Active:= True;

Any idea what could be wrong?

Edited by: Simon Lee on Feb 5, 2015 10:36 PM

Edited by: Simon Lee on Feb 5, 2015 10:38 PM
0
Simon
2/5/2015 1:01:01 AM
embarcadero.delphi.firedac 822 articles. 2 followers. Follow

2 Replies
3006 Views

Similar Articles

[PageSpeed] 38

FDMemTable operates with the data stored in memory. FDTable operates with data stored in database.
Setting FDTable.Data will temporarily populates records cache. But on next operations (eg, navigation),
FDTable will clear the cache and will populate the cache from the database. Setting FDTable.Data does
not populate the database.

Instead you should use TFDBatchMove. See (demos)\Object Pascal\Database\FireDAC\Samples\Comp Layer\TFDBatchMove\Main
demo application. Especially TfrmMain.btnTabToTabMoveClick method.


-- 
With best regards,
Dmitry Arefiev / FireDAC Architect
0
Dmitry
2/9/2015 1:01:01 AM
FDMemTable operates with the data stored in memory. FDTable operates with data stored in database.
Setting FDTable.Data will temporarily populates records cache. But on next operations (eg, navigation),
FDTable will clear the cache and will populate the cache from the database. Setting FDTable.Data does
not populate the database.

Instead you should use TFDBatchMove. See (demos)\Object Pascal\Database\FireDAC\Samples\Comp Layer\TFDBatchMove\Main
demo application. Especially TfrmMain.btnTabToTabMoveClick method.

Other option is to use FDTable.CopyDataSet method.

-- 
With best regards,
Dmitry Arefiev / FireDAC Architect

Edited by: Dmitry Arefiev on Feb 9, 2015 1:15 PM
0
Dmitry
2/9/2015 9:16:06 AM
Reply:

Similar Artilces:

How to copy a firedac dataset from FDMemTable to FDTable (SQLite connected) [Edit]
I have TDBGrids connected to FDTable1 via a Datasource component. FDTable1 is not using CachedUpdates. When I ran the code, looking at the TDBGrid, the data is copied. But when I open the SQLite database containing FDTable1, the table how is empty! // Copy query results to a FDMemTable. It works OK! FDQuery1.SQL.Text:= 'select userno, loginid from user'; FDQuery1.Open; FDQuery1.FetchAll; FDMemTable1.Active:= False; FDMemTable1.Data:= FDQuery1.Data; FDMemTable1.Active:= True; // Copy from FDMemTable to FDTable. FDConnection1.Offline; FDTable1.Active:= ...

How to copy a firedac dataset from a FDMemTable to FDTable (connected to SQ
I have TDBGrids connected to FDTable1 via a Datasource component. FDTable1 is not using CachedUpdates. When I ran the above code, looking at the TDBGrid, the data is copied. But when I open the SQLite database containing FDTable1, the table how is empty! Code… // Copy query results to a FDMemTable. It works OK! FDQuery1.SQL.Text:= 'select userno, loginid from user'; FDQuery1.Open; FDQuery1.FetchAll; FDMemTable1.Active:= False; FDMemTable1.Data:= FDQuery1.Data; FDMemTable1.Active:= True; // Copy from FDMemTable to FDTable. FDConnection1.Offline; FDTable...

FireDAC mobile app error as sqlite as delphi XE7 [Edit] #2
i im trying of connect my app as FireDAC but i have some errors. I follow all steps of Mobile_Tutotils_en_pdf file for delphi XE7. First i add one FireDAConnection compoent, after i in FireDAConnection Edit i set DriverID as Sqlite, in Database parameter i set this existing sqlite database "shoplist.s3db , and i set lockingmode to normal as this manual tell. I After i follow steps 1,2,3,4 and in the step 5 of the page 265 when i try of to set Connected property to true, i get this error: 1. [FireDac][Comp][Clnt]-340. Driver ID is not defined. Set TFDConnection.DriverName or Add D...

FireDAC / Delphi XE7 / Firebird 2.5 + Dialect 3: Key fields turn upper case [Edit] #2
Hi, When working wih a SQL dialect 3 database and field names in upper/lower case, I used to reference those fields in double quotes on my old Delphi 2010 with IBX, which worked well enough. After migrating to XE7 with the latest FireDAC, I set IndexFieldNames to "Mmm" including the double quotes. "Mmm" is also my only primary key field. When opening the table, FireDAC executes an SQL statement that ends with {code}ORDER BY A."Mmm" ASC, A.MMM ASC{code} which of course delivers an exception because there is no field MMM. I hope it is ok if I post some singl...

Cant connect to Sqlite with DbExpress or FireDac, what am I doing wrong [Edit]
Hi All, Have up till now developed using Delphi XE3 TadoConnection -> Msaccess Jet.oledb.4 Tdatasource - TAdoQuery TAdoQuery - TAdoconnection Use DBEdit and DGrid and all works well, but would now like to change to Sqlilte and have treid a number of Guides with DBExpress and Firedac and the only thing that sort of worked was a Youtube guide from Alister Christie using DBExpress BUT as soon as try to Add a TsqlQuery to pullup the data, I can get the Query to access the data BUT the Dbedit fields are NOT editable !!!!!!!, The guide I was following was: TsqlConnection - SQLite DB TSql...

FireDAC mobile app error as sqlite as delphi XE7 [Edit]
i im trying of connect my app as FireDAC but i have some errors. I follor all steps of Mobile_Tutotils_en_pdf file for delphi XE7. First i add one FireDAConnection compoent, after i in FireDAConnection Edito i set DriverID as Sqlite, in Database parameter i set this existing sqlite database "shoplist.s3db i create this database and table as other tool, and i can to add this to DBExpres in data exploer and i can to use it in one mobile delphi project", and i set lockingmode to normal as this manual tell. After as tell in page 269 of this manual when i click over test button, i ...

Delphi XE6 FireDAC SQLite copy a table from one database to another
How do I copy a single table from one SQLite database to another? Is there a simple command to do this? Thanks! > How do I copy a single table from one SQLite database to another? Is there a simple command to do this? Thanks! You should use ATTACH command. For example: {code} ATTACH 'c:\secondDB.sdb' AS sec; INSERT INTO SomeTab SELECT * FROM sec.SomeTab; {code} -- With best regards, Dmitry Arefiev / FireDAC Architect Thanks! > {quote:title=Dmitry Arefiev wrote:}{quote} > > How do I copy a single table from one SQLite database to another? Is there a...

Caution error in FireDac 8.0.1 to Delphi Xe2 and earlier [Edit] #2
Please note that FireDac 8.0.1 have a bug, Embarcadero refuses to correct an error. In December 2014 I bought FireDac to Delphi XE2, 8.0.1 a few days later it turned out that the program has a bug StrsEmpty2Null not support parameter which makes the component is not useful for me. Although embecedro 8.0.5 patch is available and I bought a legal component, has not made me any corrections. Help addicted from buying Delphi Xe 7.0 Information received from worker embecedro Poland?. Does this attitude is fair. Can someone please help me make a package 8.0.5 or help to improve the error. E...

FireDAC / Delphi XE7 / Firebird 2.5 + Dialect 3: Key fields turn upper case [Edit]
Hi, When working wih a SQL dialect 3 database and field names in upper/lower case, I used to reference those fields in double quotes on my old Delphi 2010 with IBX, which worked well enough. After migrating to XE7 with the latest FireDAC, I set IndexFieldNames to "Mmm" including the double quotes. When opening the table, FireDAC executes an SQL statement that ends with {code}ORDER BY A."Mmm" ASC, A.MMM ASC{code} which of course delivers an exception because there is no field MMM. I hope it is ok if I post some single lines of code here to explain the issue - no copyri...

FireDAC / Delphi XE7 / Firebird 2.5 + Dialect 3: Key fields turn upper case [Edit]
Hi, When working wih a SQL dialect 3 database and field names in upper/lower case, I used to reference those fields in double quotes on my old Delphi 2010 with IBX, which worked well enough. After migrating to XE7 with the latest FireDAC, I set IndexFieldNames to "Mmm" including the double quotes. "Mmm" is also my only primary key field. When opening the table, FireDAC executes an SQL statement that ends with {code}ORDER BY A."Mmm" ASC, A.MMM ASC{code} which of course delivers an exception because there is no field MMM. I hope it is ok if I post some singl...

FireDac Connection Problem [Edit]
On my first attempt to use FireDac (with a Firebird 2.5.2 sample DB) in Delphi/RAD Studio XE3 I'm having problems getting a connection. This is my Connection String: Provider=MSDASQL.1;Password=masterkey;Persist Security Info=True;User ID=SYSDBA;Data Source=C:\Program Files\Firebird\Firebird_2_5\examples\empbuild\employee.fdb;Mode=ReadWrite On testing the connection I get *Test connection failed because of an error in initializing provider. Unspecified error.* Have I chosen incorrect provider? Appreciated some help so I can move forward Edited by: Adam Gatt on Jun 6, 2013 4:...

FireDAC and Delphi Pro XE4... firedac tab not visible?
I am moving from a very old Borland product (2006) to Delphi XE4 Professional with FireDAC addon. I purchased both from Embarcadero, and have downloaded both. The documentation says the FireDAC components should automagically appear in the tabset for Delphi. They do not. I don't want to fool around too much as my environment is strictly controlled by IT, and they are very slow to do anything. Is there something that I should have done, but did not do? I installed XE4 first, registered it, then used the link in my email from Embarcadero to download the FireDAC components. Then I ra...

How to setup FireDac for slow connections [Edit]
I have some existing MS Access database on network which must be accessed by many users. I have done simple app with FireDac components and all works fine when accessed through fast network (LAN over optic cable). Pesimistic locking is used.. But users which are in distant cities are connected through ADSL connection and VPN to this LAN. When exe is loaded, and db is queryed error message is following: [FireDAC][Phys][ODBC][Microsoft][ODBC Microsoft Access Driver] (unknown) is not valid path.. What seams to be a problem? All other users have no this issue inside faster network. Is ...

Firedac not see the parameter? [Edit] #2
I use Firedac query. It does not see the parameter in the first run. See parameters in the second run. Why? TBLFisMaster.Close; TBLFisMaster.Prepared:=True; TBLFisMaster.Prepare; TBLFisMaster.ParamByName('PYEAR').AsInteger:=SPINYEAR.Value; TBLFisMaster.Open; NOTE:DELPHIXE6 and database:MS SQL 2014 Edited by: KEMAL DEMİR on May 23, 2015 1:15 AM Edited by: KEMAL DEMİR on May 23, 2015 3:51 AM > TBLFisMaster.Close; > TBLFisMaster.Prepared:=True; > TBLFisMaster.Prepare; > TBLFisMaster.ParamByName('PYEAR').AsInteger:=SPINYEAR.Value; > TBLFisMas...

Web resources about - How to copy a firedac dataset from FDMemTable to FDTable (SQLite connected) [Edit] #2 - embarcadero.delphi.firedac

Resources last updated: 1/13/2016 4:12:33 AM