namespace DataSnapClient;

interface

uses
  System.Drawing,
  System.Collections,
  System.Collections.Generic,
  System.Windows.Forms,
  System.ComponentModel;

type
  /// <summary>
  /// Summary description for MainForm.
  /// </summary>
  MainForm = partial class(System.Windows.Forms.Form)
  private
    method button1_Click(sender: System.Object; e: System.EventArgs);
  protected
    method Dispose(disposing: Boolean); override;
  public
    constructor;
  end;

implementation
uses
  System.Data;

{$REGION Construction and Disposition}
constructor MainForm;
begin
  //
  // Required for Windows Form Designer support
  //
  InitializeComponent();

  //
  // TODO: Add any constructor code after InitializeComponent call
  //
end;

method MainForm.Dispose(disposing: Boolean);
begin
  if disposing then begin
    if assigned(components) then
      components.Dispose();

    //
    // TODO: Add custom disposition code here
    //
  end;
  inherited Dispose(disposing);
end;
{$ENDREGION}

method MainForm.button1_Click(sender: System.Object; e: System.EventArgs);
var
  Client: ClientProxy1.TMyServerMethodsClient;
  Connection: Borland.Data.TAdoDbxDatasnapConnection;
  Employees: System.Data.IDataReader;
  ds: System.Data.DataSet;
  dt: System.Data.DataTable;
begin
  Connection := new Borland.Data.TAdoDbxDatasnapConnection();
  Connection.ConnectionString :=
    'communicationprotocol=http;hostname=www.bobswart.nl;port=80;' + 
    'urlpath=/DataSnapXE2/DataSnapServerRESTISAPI.dll;' + 
    'dsauthenticationuser=Bob;dsauthenticationpassword=Swart';

  Connection.Open;
  try
    Client := ClientProxy1.TMyServerMethodsClient.Create(Connection);
    Employees := Client.GetEmployees;
    ds := new DataSet();
    dt := new DataTable("DataSnap");
    ds.Tables.Add(dt);
    ds.Load(Employees, LoadOption.PreserveChanges, ds.Tables[0]);
    dataGridView1.DataSource := ds.Tables[0];

    MessageBox.Show(
      Client.EchoString('Prism XE2'));
  finally
    Connection.Close;
  end;
end;

end.
