Function DbUseArea() Foundation
Opens a database file in a work area.
DbUseArea( [<lNewArea>] , ;
[<cDBE>|<oSession>] , ;
<cFileName> , ;
[<cAlias>] , ;
[<lShared>] , ;
[<lReadonly>] ) --> NIL
The return value of DbUseArea() is always NIL.
The database function DbUseArea() opens a database file in a work area and selects the area as the current work area. If <lNewArea>contains the value .T. (true), DbUseArea() selects a free work area before opening the file. If <lNewArea> is not specified, all files in the current work area are closed before the new file is opened in the work area.
The file is searched in the following directories: 1st) the DEFAULT directory; 2nd) if this is not defined, the current directory; 3rd) the directories defined with the PATH setting.
The command USE can be used instead of DbUseArea().
Open a database several times
It is possible to open the same database file in different work areas. In this case each work area maintains its own record pointer and record locks must be set when writing data to a database field. If a database is opened more than once without specifying <cAlias>Xbase++ automatically creates a unique alias name. It is build from the file name followed by an underscore and the number of the selected work area ( <cFileName> + "_" + LTrim(Str(Select())) ).
// The example shows how to open a database file using both
// the command and function syntax.
PROCEDURE Main
USE Invoice ALIAS Inv NEW
? Alias() // result: INV
DbUseArea(.T., , "Customer", "Cust" )
? Alias() // result: CUST
CLOSE DATABASES
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.