Marco's Web Center

Menu for Development

Site Menu
Object Pascal Handbook
Delphi Handbooks Collection
Mastering Borland Delphi 2005
(Old) White Papers
(Old)Tools
(Old) Conferences

My Other Sites
Italian Site (www.marcocantu.it)
the delphi search

Spirit of delphi

Advertising
Home My Blog Books Object Pascal Marco

Home: Code Repository: Mastering Delphi 6

Chapter 14 - Project SchemaTest

Project Structure

SchemaTest.dpr
program SchemaTest;

uses
Forms,
 SchemaForm in 'SchemaForm.pas' {FormSchema};

{$R *.res}

begin
Application.Initialize;
Application.CreateForm(TFormSchema, FormSchema);
 Application.Run;
end.
SchemaForm.pas
unit SchemaForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DBXpress, FMTBcd, Provider, DBClient, DB, SqlExpr, Grids,
  DBGrids, StdCtrls;

type
  TFormSchema = class(TForm)
    btnTables: TButton;
    btnFields: TButton;
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    SQLConnection1: TSQLConnection;
    SQLDataSet1: TSQLDataSet;
    ClientDataSet1: TClientDataSet;
    DataSetProvider1: TDataSetProvider;
    procedure btnTablesClick(Sender: TObject);
    procedure btnFieldsClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormSchema: TFormSchema;

implementation

{$R *.dfm}

procedure TFormSchema.btnTablesClick(Sender: TObject);
begin
  ClientDataSet1.Close;
  SQLDataSet1.SetSchemaInfo (stTables, '', '');
 ClientDataSet1.Open;
end;

procedureTFormSchema.btnFieldsClick(Sender: TObject);
begin
  SQLDataSet1.SetSchemaInfo (stColumns,
    ClientDataSet1['Table_Name'], '');
 ClientDataSet1.Close;
 ClientDataSet1.Open;
end;

end.
SchemaForm.dfm
object FormSchema: TFormSchema
  Left = 196
  Top = 107
  Width = 643
  Height = 414
  Caption = 'SchemaTest'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object btnTables: TButton
    Left = 30
    Top = 13
    Width = 65
    Height = 22
    Caption = 'Tables'
    TabOrder = 0
    OnClick = btnTablesClick
  end
  object btnFields: TButton
    Left = 105
    Top = 13
    Width = 64
    Height = 22
    Caption = 'Fields'
    TabOrder = 1
    OnClick = btnFieldsClick
  end
  object DBGrid1: TDBGrid
    Left = 32
    Top = 48
    Width = 580
    Height = 313
    Anchors = [akLeft, akTop, akRight, akBottom]
    DataSource = DataSource1
    TabOrder = 2
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
  end
  object DataSource1: TDataSource
    DataSet = ClientDataSet1
    Left = 200
    Top = 72
  end
  object SQLConnection1: TSQLConnection
    ConnectionName = 'IBLocal'
    DriverName = 'Interbase'
    GetDriverFunc = 'getSQLDriverINTERBASE'
    LibraryName = 'dbexpint.dll'
    LoginPrompt = False
    Params.Strings = (
      'BlobSize=-1'
      'CommitRetain=False'

              'Database=c:\program files\interbase corp\interbase6\examples\dat' +
        'abase\employee.gdb'
      'DriverName=Interbase'
      'LocaleCode=0x0000'
      'Password=masterkey'
      'RoleName=RoleName'
      'ServerCharSet=ASCII'
      'SQLDialect=1'
      'Interbase TransIsolation=ReadCommited'
      'User_Name=sysdba'
      'WaitOnLocks=True')
    VendorLib = 'GDS32.DLL'
    Left = 72
    Top = 168
  end
  object SQLDataSet1: TSQLDataSet
    SQLConnection = SQLConnection1
    Params = <>
    Left = 184
    Top = 168
  end
  object ClientDataSet1: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'DataSetProvider1'
    Left = 312
    Top = 80
  end
  object DataSetProvider1: TDataSetProvider
    DataSet = SQLDataSet1
    Constraints = True
    Left = 272
    Top = 136
  end
end