Webservice 返回数据集 DataSet 及Android显示数据集LiveBindings

时间:2022-10-11 22:54:29

一、服务端

New TSoapDataModule

添加控件 TDataSetProvider,TClientDataSet,TADOQuery,TADOConnection

添加方法

function TsoapTest.Getdata(const sql: UTF8String): Variant;
begin
  dm.ADOQuery1.Close;
  dm.ADOQuery1.sql.Text := 'select top 50 * from mz';
  dm.ADOQuery1.Open;
  dm.ClientDataSet1.Data := dm.DataSetProvider1.Data;
  Result := dm.ClientDataSet1.XMLData;
end;

客户端VCL

procedure TForm25.btnGetDataClick(Sender: TObject);
begin
    HTTPRIO1.URL := 'http://localhost:8080/soap/IsoapTest';
  ClientDataSet1.XMLData := (HTTPRIO1 as IsoapTest).Getdata('');
end;

Webservice 返回数据集 DataSet 及Android显示数据集LiveBindings

Android客户端

FireMonkey客户端平台

  • StringGrid显示数据
procedure TForm4.btnGetDataSetClick(Sender: TObject);
var
i: Integer;
begin
HTTPRIO1.URL := 'http://localhost:8080/soap/IsoapTest';
ClientDataSet1.XMLData := (HTTPRIO1 as IsoapTest).Getdata(''); i := ;
StringGrid1.RowCount := ClientDataSet1.RecordCount;
while not ClientDataSet1.Eof do
begin
StringGrid1.Cells[, i] := ClientDataSet1.FieldByName('代码').AsWideString;
StringGrid1.Cells[, i] := ClientDataSet1.FieldByName('民族').AsString;
StringGrid1.Cells[, i] := ClientDataSet1.FieldByName('拼音码').AsString;
i := i + ;
ClientDataSet1.Next;
end;
end;

Webservice 返回数据集 DataSet 及Android显示数据集LiveBindings

  • android 用Grid展示数据

HTTPRIO1.URL := 'http://localhost:8080/soap/IsoapTest';
  ClientDataSet1.XMLData := (HTTPRIO1 as IsoapTest).Getdata('');

运行 LiveBindings Wizard向导 选择Grid>ClientDataSource就关联上了,不用写代码数据就出来了

StringGrid、Grid都可以这样!!

Webservice 返回数据集 DataSet 及Android显示数据集LiveBindings

Webservice 返回数据集 DataSet 及Android显示数据集LiveBindings

Webservice 返回数据集 DataSet 及Android显示数据集LiveBindings

Webservice 返回数据集 DataSet 及Android显示数据集LiveBindings

Webservice 返回数据集 DataSet 及Android显示数据集LiveBindings