best way to copy blobs from SDAC to LiteDAC over the network in Firemonkey FMX

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
witzl
Posts: 14
Joined: Fri 21 Apr 2017 10:01

best way to copy blobs from SDAC to LiteDAC over the network in Firemonkey FMX

Post by witzl » Fri 21 Sep 2018 09:11

Hi,

on serverside I have a SQL-Servertable, with 5000 blobs:

SQLServerTable:
ID: Integer
Pic: VarBinary

In my Firemonkey IOS App I have SDAC-Client and LiteDAC client.

SQLIteTable:
ID: Integer
Pic: VarBinary

I can connect via network to the SQLServerTable and want to copy the data to my local SQLiteTable.

What is the best way to copy the data?

Case 1:

Code: Select all

SQLServerTable : TMSQuery;
SQLiteTable : TLiteQuery;
SQLServerTable.SQL.Text := 'select ID, Pic from SQLServerTable';
SQLServerTable.open;

SQLiteTable.SQL.Text :=  'select ID, Pic from SQLiteTable';
SQLiteTable.open;

while not SQLServerTable.eof do begin
  SQLiteTable.Insert;
  SQLiteTable.FieldByName('ID').Value :=  SQServerTable.FieldByName('ID').Value;
  SQLiteTable.Post;
  SQLServerTable.next;
end;
SQLiteTable.Close;
SQLServerTable.Close;
Or should I use TLiteScript with parameters:

Case 2:

Code: Select all

SQLServerTable : TMSQuery;
SQLiteScript : TLiteScript;

SQLServerTable.SQL.Text := 'select ID, Pic from SQLServerTable';
SQLServerTable.open;

SQLiteScript.SQL.Text := 'insert into SQLiteTable (ID, PIC) values (:ID, :PIC)';

while not SQLServerTable.eof do begin
  SQLiteScript.ParamByName('ID').Value := SQServerTable.FieldByName('ID').Value;
  SQLiteScript.ParamByName('PIC').Value := SQServerTable.FieldByName('PIC').Value;
  SQLiteScript.Execute;
  SQLServerTable.next;
end;
SQLServerTable.Close;
Or do you have a better way? BulkCopy?

Case 2 doesn't work, the Pics are NOT copied!

Thanks in advance,
Dietrich

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: best way to copy blobs from SDAC to LiteDAC over the network in Firemonkey FMX

Post by MaximG » Sat 22 Sep 2018 09:26

We have answered you in the forum. Please view the following topic:

https://forums.devart.com/viewtopic. ... 61#p131561

Post Reply