TDataSetActive (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example requires a database with the following name or in the form of a *.DB file in the following path. The table should be closed when changing the database.

Code

procedure TForm1.Button1Click(Sender: TObject);
begin
  Customers.Active := False;
  try
  { First try to use an alias. }
    Customers.DatabaseName := 'DBDEMOS';
    Customers.Active := True;
  except
    on EDatabaseError do
    begin
      { If that fails, try to use the drive and directory. }
      Customers.TableName := 'Flights';
      // This path depends on the Demos directory of your RAD Studio installation.
      Customers.DatabaseName :=
        'c:\Documents and Settings\All Users\Documents\RAD Studio\6.0\Demos\IntraWeb\Win32\FlightInformation\Data';
      Customers.Active := True;
    end;
  end;
end;

Uses