How can i Save the Query Data in Server-side And Load to cds
How can i Save the Query Data in Server-side And Load to cds
hello:
how can i save the uniquery(other query same ok, i can only know uniquery) data to stream in server-side, and load data to cds in client;
i know one method: uniquery.savetoxml ado stream and client restore but xml and ado is slow, has other way fast? server - lazarus, client-delphi
2: TVirtualTable loadfromstream and
RS := CreateOleObject('ADODB.Recordset');
RS.Open(TStreamAdapter.Create(Stream) as IUnknown);
tempAdoDataSet.Recordset := IUnknown(RS) as _Recordset;
load from stream
provide.dataset= virtualtable; cds.data := provide.data;
provide.dataset= tempAdoDataSet; cds.data := provide.data;
which is fast?
how can i save the uniquery(other query same ok, i can only know uniquery) data to stream in server-side, and load data to cds in client;
i know one method: uniquery.savetoxml ado stream and client restore but xml and ado is slow, has other way fast? server - lazarus, client-delphi
2: TVirtualTable loadfromstream and
RS := CreateOleObject('ADODB.Recordset');
RS.Open(TStreamAdapter.Create(Stream) as IUnknown);
tempAdoDataSet.Recordset := IUnknown(RS) as _Recordset;
load from stream
provide.dataset= virtualtable; cds.data := provide.data;
provide.dataset= tempAdoDataSet; cds.data := provide.data;
which is fast?
-
AndreyZ
Hello,
You can use the TVirtualTable on the both server and client sides. On the sever side, you should save data in the following way:, and on the client side, load data to TVirtualTable in the following way:
You can use the TVirtualTable on the both server and client sides. On the sever side, you should save data in the following way:
Code: Select all
procedure TForm1.BitBtn1Click(Sender: TObject);
var
fs: TFileStream;
begin
fs := TFileStream.Create('filename', fmCreate);
try
UniQuery.Open;
VirtualTable.Assign(UniQuery); // you can use any TDataSet descedants here instead of TUniQuery
VirtualTable.SaveToStream(fs);
finally
fs.Free;
end;
end;Code: Select all
procedure TForm1.BitBtn1Click(Sender: TObject);
var
fs: TFileStream;
begin
fs := TFileStream.Create('filename', fmOpenRead);
try
VirtualTable.Open;
VirtualTable.LoadFromStream(fs);
finally
fs.Free;
end;
end;thanks, new question: same code run in delphi7 but not laz?
unidac 4.1.3
delphi7, lazarus 0.9.30
same code to conn to oracle , delphi is ok, but lazarus not run, why?
by the way, if can, provide some laza demo, thanks!
var
UniConnection: TUniConnection;
begin
UniConnection:= TUniConnection.Create(nil);
UniConnection.ProviderName := 'Oracle';
UniConnection.SpecificOptions.Clear;
UniConnection.SpecificOptions.Add('Oracle.Direct=True');
// UniConnection.SpecificOptions.Add('Oracle.PrecisionInteger=11');
UniConnection.Server := '10.0.0.2:1521:jzxs';
UniConnection.Username := 'system';
UniConnection.Password := '000';
UniConnection.Connect;
if UniConnection.connected then
Showmessage('ok')
else
Showmessage('error')
end;
delphi7, lazarus 0.9.30
same code to conn to oracle , delphi is ok, but lazarus not run, why?
by the way, if can, provide some laza demo, thanks!
var
UniConnection: TUniConnection;
begin
UniConnection:= TUniConnection.Create(nil);
UniConnection.ProviderName := 'Oracle';
UniConnection.SpecificOptions.Clear;
UniConnection.SpecificOptions.Add('Oracle.Direct=True');
// UniConnection.SpecificOptions.Add('Oracle.PrecisionInteger=11');
UniConnection.Server := '10.0.0.2:1521:jzxs';
UniConnection.Username := 'system';
UniConnection.Password := '000';
UniConnection.Connect;
if UniConnection.connected then
Showmessage('ok')
else
Showmessage('error')
end;