zoukankan      html  css  js  c++  java
  • Webservice 返回数据集 DataSet 及Android显示数据集LiveBindings

    一、服务端

    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;

    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 := 0;
      StringGrid1.RowCount := ClientDataSet1.RecordCount;
      while not ClientDataSet1.Eof do
      begin
        StringGrid1.Cells[0, i] := ClientDataSet1.FieldByName('代码').AsWideString;
        StringGrid1.Cells[1, i] := ClientDataSet1.FieldByName('民族').AsString;
        StringGrid1.Cells[2, i] := ClientDataSet1.FieldByName('拼音码').AsString;
        i := i + 1;
        ClientDataSet1.Next;
      end;
    end;

    • android 用Grid展示数据

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

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

    StringGrid、Grid都可以这样!!

  • 相关阅读:
    自习任我行第二阶段个人总结5
    自习任我行第二阶段个人总结4
    自习任我行第二阶段个人总结3
    自习任我行第二阶段个人总结2
    自习任我行第二阶段个人每日总结1
    bootstrap table
    log4j2 的使用
    新版本MySQL Server 5.7的免安装版本设置
    工作随笔 2016-5-19
    在windows 下安装启动redis
  • 原文地址:https://www.cnblogs.com/cb168/p/3891761.html
Copyright © 2011-2022 走看看