Delphi Database, Delphi Components from ComponentAce
Products Download Order Contact us
Create Table Example
Top 



  {set up database component}
  ABSDatabase1.DatabaseName := 'emp_db'
;
  ABSDatabase1.DatabaseFileName := 'c:\data\employee_db.abs'
;

  {set up table component}

  ABSTable1.DatabaseName := 'emp_db'
;
  ABSTable1.TableName := 'employee'
;

  with ABSTable1 do
   begin
     {specifying table fields}

     with FieldDefs do
   begin
      Clear;
         Add('EmpNo'
,ftAutoInc,0,False);
         Add('LastName'
,ftString,20,False);
         Add('FirstName'
,ftString,15,False);
         Add('PhoneExt'
,ftString,4,False);
         Add('HireDate'
,ftDate,0,False);
         Add('Salary'
,ftCurrency,0,False);
    end;
     {specifying table indexes}

     with IndexDefs do
       begin
         Clear;
         Add('idxPrimary'
,'EmpNo',[ixPrimary]);
         Add('idxByLastNameFirstName'
,'LastName;FirstName',[ixCaseInsensitive]);
       end;
   end;

  {create the database}

  with ABSDatabase1 do
   {if database file doesn't exist}

    if not Exists then
      CreateDatabase;

  {and create the table}

  with ABSTable1 do
   {if table doesn't exist}

    if not Exists then
      CreateTable;

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