首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

RO 本地sql动态指令检索使用方法

Posted on 2011-08-09 15:09  colincode  阅读(797)  评论(0编辑  收藏  举报

procedure TForm1.btn3Click(Sender: TObject);
var
lDataSet:IDADataSet;
lConnection:IDAConnection ;
stream: Binary;
mytbl:TDAMemDataTable ;
begin
mytbl :=tbl1;


lConnection := DAConnectionManager.NewConnection(DAConnectionManager.Connections[0].Name);
lDataSet := lConnection.NewDataset('select * from db_ip', 'SQLResult');
lDataSet.Open ;

with mystreamer do
try
    stream := Binary.Create;
    // Writes the data
    Initialize(stream, aiWrite);
    WriteDataset(lDataSet, [woSchema,woRows], -1);
    Finalize;
    // End of write data
    mytbl.Close ;
    mytbl .RemoteFetchEnabled :=False;
    mytbl.LocalSchema :=nil;
    mytbl.LocalDataStreamer :=nil;
    //read
    Initialize(stream, aiReadFromBeginning);
    ReadDataset('SQLResult', mytbl, true);
    Finalize;
    //end
   finally
    stream.Free;
end;
end;

end.