Page 1 of 1

How can i Save the Query Data in Server-side And Load to cds

Posted: Mon 02 Apr 2012 15:15
by c123321
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?

Posted: Tue 03 Apr 2012 14:50
by 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:

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;
, and on the client side, load data to TVirtualTable in the following way:

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?

Posted: Tue 03 Apr 2012 17:58
by c123321
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;

Posted: Wed 04 Apr 2012 07:05
by AlexP
Hello,

Currently ODAC does not support the direct mode in Lazarus, the direct mode support for Lazarus will be implemented in the next version of ODAC

Posted: Wed 04 Apr 2012 09:09
by c123321
UNIDAC , NOT ODAC, this time not support direct mode in lazarus?
realy the next minor version will support?

Posted: Wed 04 Apr 2012 10:08
by AlexP
Hello,

UniDAC Oracle provider is based on ODAC and currently doesn't support the Direct mode for Lazarus too. This support will be implemented in the next major version.

Posted: Wed 04 Apr 2012 14:39
by c123321
thinks, i see;