.NET Zip component, Delphi Zip component, Barcode .NET, BDE Replacement and other .NET and Delphi components from ComponentAce
Products Download Order Contact us

Search
 

Delphi/C++ Components
.NET Components
ActiveX Controls
Kylix Components

Download

Download
Download Commercial
Trial Limitations

Support

Submit Request
Support Options

Order

Purchase
Competitive Upgrade
Premium Support
Sales Policy
Upgrade Policy
License Types

Info

News
Mailing List
Articles
Testimonials



About Us
Partners
Links
Contact Us
Link to Us





Home > Delphi/C++ Components > Absolute Database > Restructure Table Delphi Example

Absolute Database

Overview | Features | Requirements | Testimonials | SQL Samples | Code Samples | Screenshots | See Also | Download | Order
Restructure Table Delphi Example
Illustrates how to Restructure Table via Query and Table components

Download Absolute Database | Learn more

unit Main;

interface
{$I CompVer.inc}

uses
{$IFDEF D6H}
  Variants,
{$ENDIF}
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, ABSMain, DB, ExtCtrls, DBCtrls, Grids, DBGrids, StdCtrls;

const DataBaseFileName = '..\..\Data\Demos.abs';

type
  TForm1 = class(TForm)
    dbDemos: TABSDatabase;
    tEmployeeDemos: TABSTable;
    tEmployeeMemory: TABSTable;
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    btnInit: TButton;
    mSQL: TMemo;
    Query: TABSQuery;
    GroupBox2: TGroupBox;
    rbTable: TRadioButton;
    rbQuery: TRadioButton;
    btnRestructure: TButton;
    Label2: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure btnInitClick(Sender: TObject);
    procedure btnRestructureClick(Sender: TObject);
    procedure rbTableClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  dbDemos.DatabaseFileName := ExtractFilePath(Application.ExeName) + DataBaseFileName;
  dbDemos.Open;
  btnInitClick(nil);
end;

procedure TForm1.btnInitClick(Sender: TObject);
begin
  tEmployeeMemory.Close;
  if tEmployeeMemory.Exists then tEmployeeMemory.DeleteTable;
  tEmployeeDemos.CopyTable(tEmployeeDemos.TableName, tEmployeeMemory.DatabaseName);
  // Drop All Indexes
  tEmployeeMemory.Open;
  tEmployeeMemory.Close;
  tEmployeeMemory.RestructureIndexDefs.Clear;
  tEmployeeMemory.RestructureTable;
  tEmployeeMemory.Open;
end;

procedure TForm1.btnRestructureClick(Sender: TObject);
var
 i: Integer;
begin
 tEmployeeMemory.Close;
 try
   if rbQuery.Checked then
    begin
     Query.SQL.Text := mSQL.Text;
     Query.ExecSQL;
    end
   else
    begin
     tEmployeeMemory.RestructureFieldDefs.DeleteFieldDef('LastName');
     tEmployeeMemory.RestructureFieldDefs.Find('FirstName').Name := 'Name';
     tEmployeeMemory.RestructureTable;
    end;
 finally
   tEmployeeMemory.Open;
 end;
end;

procedure TForm1.rbTableClick(Sender: TObject);
begin
  mSQL.Enabled := rbQuery.Checked;
end;

end.



Restructure Table Delphi Example
Download Absolute Database | Learn more


Product Info


Current version: 7.95
Released: February 08, 2023
Price: $ 149

downloadorder


Our Customers



Testimonials

The other people in the office didn't believe me when I said that all I had to do was document the problem and you would probably give me a fix overnight. Unbelievable! Keep up the great work. I hope you guys all make a fortune out of this product because it is truly fantastic and the support is the best I have ever encountered.

Mark Kefford

        © 2003 - 2024 ComponentAce  | .net zip component | barcode for .net | delphi zip component | delphi database Dec 22, 2024