Bde.DBTables.TSession.FindDatabase

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function FindDatabase(const DatabaseName: string): TDatabase;

C++

TDatabase* __fastcall FindDatabase(const System::UnicodeString DatabaseName);

Properties

Type Visibility Source Unit Parent
function public
Bde.DBTables.pas
Bde.DBTables.hpp
Bde.DBTables TSession

Description

Searches a session's list of database components for a specified database.

Call FindDatabase to determine whether or not a specified database is associated with a session. DatabaseName specifies the name of the database component for which to search.

FindDatabase compares DatabaseName to the DatabaseName property for each database component in a session's list. If a match is found, FindDatabase returns a pointer to the database component. Otherwise FindDatabase returns nil (Delphi) or NULL (C++).

An application can call FindDatabase to see if a database component already exists before creating a new database component for a session.


var
DB: TDatabase;
begin
DB := Session.FindDatabase('DBDEMOS');
if (DB = nil) then { database doesn't exist for session so,}
DB := Session.OpenDatabase('DBDEMOS'); { create and open it}
if Assigned(DB) and DB.Active then begin
DB.StartTransaction;
...
end;
end;


See Also