home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Books / 4 / EX20.ZIP / MAIN.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1996-01-10  |  1.7 KB  |  83 lines

  1. unit Main;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, Buttons, StdCtrls, Grids, DBGrids, DB;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     DataSource1: TDataSource;
  13.     DBGrid1: TDBGrid;
  14.     Label1: TLabel;
  15.     ListBox1: TListBox;
  16.     BitBtn1: TBitBtn;
  17.     procedure Button1Click(Sender: TObject);
  18.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  19.   private
  20.     { Private declarations }
  21.   public
  22.     { Public declarations }
  23.   end;
  24.  
  25. var
  26.   Form1: TForm1;
  27.  
  28. implementation
  29.  
  30. uses
  31.   DBTables;
  32.  
  33. {$R *.DFM}
  34.  
  35. var
  36.   Table1:TTable;
  37.  
  38. procedure TForm1.Button1Click(Sender: TObject);
  39. var
  40.   i:integer;
  41. begin
  42.   if Table1=nil then
  43.     Table1:=TTable.Create(nil);
  44.   with Table1 do
  45.   begin
  46.     DatabaseName:='dbdemos';
  47.     TableName:='mytest';
  48.     TableType:=ttParadox;
  49.     {╤ετΣα≥ⁿ ∩εδ }
  50.     with FieldDefs do
  51.     begin
  52.       Add('Surname',ftString,30,true);
  53.       Add('Name',ftString,25,true);
  54.       Add('Patronymic',ftString,25,true);
  55.       Add('Age',ftInteger,0,false);
  56.       Add('Weight',ftFloat,0,false);
  57.     end;
  58.     {╤πσφσ≡Φ≡εΓα≥ⁿ ΦφΣσΩ±√}
  59.     with IndexDefs do
  60.     begin
  61.       Add('I_Name','Surname;Name;Patronymic',[ixPrimary,ixUnique]);
  62.       Add('I_Age','Age',[ixCaseInsensitive]);
  63.     end;
  64.     CreateTable;
  65.   end;
  66.   DataSource1.DataSet:=Table1;
  67.   Table1.Open;
  68.   {╬≥εß≡ατΦ∞ ΦφΣσΩ±√ Σδ  ∩≡ε±∞ε≥≡α}
  69.   for i:=0 to Table1.IndexDefs.Count-1 do
  70.   begin
  71.     with Table1.IndexDefs.Items[i] do
  72.       ListBox1.Items.Add(Name+' ('+Fields+')');
  73.   end;
  74. end;
  75.  
  76. procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
  77. begin
  78.   if Table1<>nil then
  79.     Table1.Free;
  80. end;
  81.  
  82. end.
  83.