To open a database connection within a session, call the OpenDatabase method. OpenDatabase takes one parameter, the name of the database to open. This name is a BDE alias or the name of a database component. For Paradox or dBASE, the name can also be a fully qualified path name. For example, the following statement uses the default session and attempts to open a database connection for the database pointed to by the DBDEMOS alias:
var DBDemosDatabase: TDatabase; begin DBDemosDatabase := Session.OpenDatabase('DBDEMOS'); ...
TDatabase *BCDemosDatabase = Session->OpenDatabase("BCDEMOS");
OpenDatabase actives the session if it is not already active, and then checks if the specified database name matches the DatabaseName property of any database components for the session. If the name does not match an existing database component, OpenDatabase creates a temporary database component using the specified name. Finally, OpenDatabase calls the Open method of the database component to connect to the server. Each call to OpenDatabase increments a reference count for the database by 1. As long as this reference count remains greater than 0, the database is open.
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|