.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 > Copy Table Delphi Example

Absolute Database

Overview | Features | Requirements | Testimonials | SQL Samples | Code Samples | Screenshots | See Also | Download | Order
Copy Table Delphi Example
Shows how to copy a database table.

Download Absolute Database | Learn more

unit Main;

interface
{$I CompVer.inc}

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

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

type
  TfrmMain = class(TForm)
    Label1: TLabel;
    lvTables: TListView;
    GroupBox1: TGroupBox;
    Label3: TLabel;
    dbDemos: TABSDatabase;
    ABSTable1: TABSTable;
    Bevel1: TBevel;
    Label2: TLabel;
    eTableName: TEdit;
    rbCurrentDb: TRadioButton;
    rbSelectedDb: TRadioButton;
    eDbFileName: TEdit;
    odOpenDatabase: TOpenDialog;
    btnDbFileSelect: TButton;
    btCopy: TButton;
    ePassword: TEdit;
    cbEncrypted: TCheckBox;
    Label4: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure btCopyClick(Sender: TObject);
    procedure btnDbFileSelectClick(Sender: TObject);
    procedure lvTablesChange(Sender: TObject; Item: TListItem;
      Change: TItemChange);
    procedure rbCurrentDbClick(Sender: TObject);
    procedure rbSelectedDbClick(Sender: TObject);
  private
    { Private declarations }
    procedure FillTablesList;
  public
    { Public declarations }
  end;

var
  frmMain: TfrmMain;

implementation

{$R *.dfm}

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

procedure TfrmMain.btnDbFileSelectClick(Sender: TObject);
begin
  if odOpenDatabase.Execute then
    eDbFileName.Text := odOpenDatabase.FileName;
end;

procedure TfrmMain.btCopyClick(Sender: TObject);
begin
  if (lvTables.Selected <> nil) then
    begin
      ABSTable1.TableName := lvTables.Selected.Caption;
      if (rbCurrentDb.Checked) then
        begin
          ABSTable1.CopyTable(eTableName.Text);
          FillTablesList;
        end
      else
        if (not cbEncrypted.Checked) then
          ABSTable1.CopyTable(eTableName.Text, eDbFileName.Text)
        else
          ABSTable1.CopyTable(eTableName.Text, eDbFileName.Text, ePassword.Text);
      MessageDlg('Table copied.', mtInformation, [mbOK], 0);
    end
  else
    MessageDlg('Please select table to copy from the list', mtInformation, [mbOK], 0);
end;

procedure TfrmMain.FillTablesList;
var
  tables: TStringList;
  i: integer;
begin
  tables := TStringList.Create;
  try
    lvTables.Items.Clear;
    dbDemos.GetTablesList(tables);
    for i:=0 to tables.Count-1 do
      lvTables.Items.Add.Caption := tables[i];
  finally
    tables.free;
  end;
end;

procedure TfrmMain.lvTablesChange(Sender: TObject; Item: TListItem;
  Change: TItemChange);
begin
  if (lvTables.Selected <> nil) then
    eTableName.Text := lvTables.Selected.Caption+'_copy';
end;

procedure TfrmMain.rbCurrentDbClick(Sender: TObject);
begin
  eDbFileName.Enabled := False;
  cbEncrypted.Enabled := False;
  ePassword.Enabled := False;
end;

procedure TfrmMain.rbSelectedDbClick(Sender: TObject);
begin
  eDbFileName.Enabled := True;
  cbEncrypted.Enabled := True;
  ePassword.Enabled := True;
end;

end.



Copy Table Delphi Example
Download Absolute Database | Learn more


Product Info


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

downloadorder


Our Customers



Testimonials

Thanks again for the superb tech support, I was worried I'd hit a brick wall this close to the finish line. Even working on the weekend... you guys rock!!!

Bob Boyd

        © 2003 - 2024 ComponentAce  | .net zip component | barcode for .net | delphi zip component | delphi database Nov 21, 2024