Delphi Database, Delphi Components from ComponentAce
Products Download Order Contact us
Opening and Closing Tables
Previous  Top  Next



Opening a table

To read or write data in a table, an application must first open it.

1.Place TABSDatabase and TABSTable components from the Absolute DB page of the Component palette to a data module or on a form, if you have not already done it.  
2.Set up TABSDatabase component. Set the TABSDatabase.DatabaseName of the component to a unique value that will be used later to identify the database. Set the TABSDatabase.DatabaseFileName property to the name of the existing or new database file, if you have not already done it.  
3.Set up TABSTable component. Set the TABSTable.DatabaseName property from the drop-down list of available TABSDatabase components. Set the TABSTable.TableName property to the name of the table to create, if you have not already done it.  
4.Set additional TABSTable properties (optional). Set ReadOnly, InMemory, Exclusive properties of TABSTable component.  
5.Connect to a database (optional).  
6. Open a table. You can open a table in two ways,
·Set the Active property of the table to True, either at design time in the Object Inspector, or in code at runtime: ABSTable1.Active := True;  
·Call the Open method for the table at runtime, ABSTable1.Open;  

Example:

  {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'
;

  {open table}

  if (not ABSDatabase1.Exists) then
    raise Exception.Create('Database file does not exist'
);
  if (not ABSTable1.Exists) then
    raise Exception.Create('Table "employee" does not exist'
);
  ABSTable1.Active := True;



Closing a table

You can close a dataset in two ways,
·Set the Active property of the table to False, either at design time in the Object Inspector, or in code at runtime, ABSTable1.Active := False;  
·Call the Close method for the dataset at runtime, ABSTable1.Close;  
        © 2003 - 2024 ComponentAce  | .net zip component | barcode for .net | delphi zip component | delphi database Dec 04, 2024