unit Shapes;

interface

uses
	Borland.Win32.Windows,
	Borland.Win32.Messages,
	Borland.Delphi.SysUtils,
	Borland.Delphi.Variants,
	Borland.Delphi.Classes,
	Borland.Vcl.Graphics,
	Borland.Vcl.Controls,
	Borland.Vcl.Forms,
	Borland.Vcl.Dialogs,
	Borland.Vcl.StdCtrls,
	Borland.Vcl.ExtCtrls,
  Borland.Db.DB,
  Borland.Db.BDE.DbTables,
  Borland.Db.CDS.DBClient,
  Borland.Db.Vcl.DBGrids,
  Borland.Db.CDS.Provider;

type
  TForm1 = class(TForm)
    Table1 : TTable;
    DS1 : TDataSource;
    aCDS : TClientDataSet;
    Provider1 : TDataSetProvider;
    Grid1 : TDBGrid;
  private
    { Private declarations }
		procedure InitializeControls;
  public
    { Public declarations }
		constructor Create(AOwner: TComponent); override;
  end;

var
  Form1: TForm1;

implementation


constructor TForm1.Create(AOwner: TComponent);
begin
	inherited Create(AOwner);
	InitializeControls;
end;

procedure TForm1.InitializeControls;
begin
  // Initalizing all controls...
  Table1 := TTable.Create(Self);
  Table1.DatabaseName := ExtractFilePath(Application.ExeName);
  Table1.TableName := 'employee.db';

  DS1 := TDataSource.Create(Self);
  DS1.DataSet := Table1;

  Grid1 := TDBGrid.Create(Form1);
  Grid1.Parent := Self;
  Grid1.SetBounds(10, 10, 500, 300);
  Grid1.DataSource := DS1;

  Provider1 := TDataSetProvider.Create(Self);
  Provider1.DataSet := Table1;
  Provider1.ResolveToDataSet := True;
  Provider1.Name := 'Provider1';

  aCDS := TClientDataSet.Create(Self);
  aCDS.ProviderName := 'Provider1';
  try
    Table1.Active := True;
    aCDS.Active := True;
  except
    on ex: Exception do
      Self.Caption := ex.Message;
  end;
end;

end.
