EasyTable: Single-File Embedded Database,
a BDE replacement for Delphi and C++Builder



Creating a database
Previous  Top  Next


You may create a new database by doing the following steps with TEasyDatabase component:

1.Set the DatabaseName property to a unique value that will be used to identify the database.  
2.Set the DatabaseFileName property to the name of a database file to access.  
3.Check Exists property (optional) to know whether database with specified name already exists.  
4.Call CreateDatabase method.  

Warning:   If you create a database that duplicates the name of an existing database file, the existing database and all its data are overwritten by the newly created database. The old database and its data cannot be recovered.

The following code creates a new database at runtime. Before it creates the new database, it verifies that the database file name provided does not match the name of an existing database:

var
  NewDatabase: TEasyDatabase;
begin
  NewDatabase := TEasyDatabase.Create(
nil);
  
with NewDatabase do
  begin
    Connected := false;
    DatabaseName := 'CustomerDB';
    DatabaseFileName := 'c:.edb';
    Now check for prior existence of this database
    
if not Exists then
      CreateDatabase; create the database
  end;

end;


© AidAim Software EasyTable: Easytable Bde Alternative Single File Delphi Databas