.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 > Create Database Delphi Example

Absolute Database

Overview | Features | Requirements | Testimonials | SQL Samples | Code Samples | Screenshots | See Also | Download | Order
Create Database Delphi Example
Illustrates how to Create Database

Download Absolute Database | Learn more

unit Main;

interface
{$I CompVer.inc}

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

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

type
  TfrmMain = class(TForm)
    db: TABSDatabase;
    btnCreateDefaultDatabase: TButton;
    Label1: TLabel;
    btnCreateCustomDatabase: TButton;
    lvTables: TListBox;
    Label2: TLabel;
    btnDropDatabase: TButton;
    sdDatabase: TSaveDialog;
    Label3: TLabel;
    dbDemos: TABSDatabase;
    Table: TABSTable;
    GroupBox1: TGroupBox;
    Label4: TLabel;
    procedure btnCreateCustomDatabaseClick(Sender: TObject);
    procedure btnDropDatabaseClick(Sender: TObject);
    procedure btnCreateDefaultDatabaseClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure CopyTables;
  end;

var
  frmMain: TfrmMain;

implementation

uses uDatabase;

{$R *.dfm}

procedure TfrmMain.btnCreateCustomDatabaseClick(Sender: TObject);
begin
  if frmDatabase.ShowModal = mrOk then
    begin
     db.PageSize := StrToInt(frmDatabase.cbPageSize.Text);
     db.PageCountInExtent := StrToInt(frmDatabase.cbPageCountInExtent.Text);
     db.MaxConnections := StrToInt(frmDatabase.eMaxConnections.Text);
     if frmDatabase.cbEncrypted.Checked then
      begin
       db.Password := frmDatabase.ePassword1.Text;
       db.CryptoAlgorithm := TABSCryptoAlgorithm(frmDatabase.cbCryptoAgorithm.ItemIndex);
      end
     else
      begin
       db.Password := '';
      end;
      btnCreateDefaultDatabaseClick(Sender);
    end;
end;

procedure TfrmMain.btnCreateDefaultDatabaseClick(Sender: TObject);
begin
  if sdDatabase.Execute then
   begin
    db.Close;
    db.DatabaseFileName := sdDatabase.FileName;
    db.CreateDatabase;
    CopyTables;
    db.GetTablesList(lvTables.Items);
   end;
end;

procedure TfrmMain.CopyTables;
var
  TableList: TStringList;
  i: Integer;
begin
  TableList := TStringList.Create;
  try
    dbDemos.GetTablesList(TableList);
    for i:=0 to TableList.Count-1 do
     begin
      Table.TableName := TableList[i];
      try
        Table.CopyTable(Table.TableName, db.DatabaseFileName, db.Password);
      except
        on e: Exception do
          MessageDlg(e.Message, mtError, [mbOK], 0);
      end;
     end;
  finally
    TableList.Free;
  end;
end;

procedure TfrmMain.btnDropDatabaseClick(Sender: TObject);
var s: String;
begin
  s := 'Delete (Drop) Database ''' + db.DatabaseFileName + '''.'#13#10'Are you sure?';
  if (MessageDlg(s, mtConfirmation, [mbYes,mbNo,mbCancel],0) = mrYes) then
   begin
    db.Close;
    db.DeleteDatabase;
    lvTables.Clear;
   end;
end;

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

end.



Create Database Delphi Example
Download Absolute Database | Learn more


Product Info


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

downloadorder


Our Customers



Testimonials

We made three requests of the technical support personnel and despite the fact that these were all implementation questions (not bugs in their software) we received support within 24 hours. It is rare to get such good customer support these days and I really appreciate everything ComponentAce has done for us.

Jason Goodridge, Development Manager

        © 2003 - 2024 ComponentAce  | .net zip component | barcode for .net | delphi zip component | delphi database Mar 19, 2024