| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Opens a database file in a work area.
DbUseArea( [<lNewArea>] , ;
[<cRddName>] , ;
<cDatabase> , ;
[<cAlias>] , ;
[<lShared>] , ;
[<lReadonly>] , ;
[<cCodePage>] , ;
[<nConnection>] ) --> NIL
The return value is always NIL.
DbUseArea() opens an existing database file named <cDatabase> in the current work area, or in the next unused work area when <lNewArea> is set to .T. (true). The file is searched in the following directories: first in the current directory, then in the SET DEFAULT directory and finally in all directories specified with SET PATH. If the file cannot be found, a runtime error is raised.
When a database is to be accessed in a network, it should be opened in SHARED mode, since EXCLUSIVE usage of a database file prevents other work stations from accessing the file. Shared database access requires to lock a database before changes can be written to a file. Refer to RLock() and FLock() for information about record and file locks in shared database access.
| See also: | CLOSE, DbCloseArea(), NetDbUse(), RddSetDefault(), Select(), SET DEFAULT, SET PATH, Set(), USE |
| Category: | Database functions |
| Source: | rdd\dbcmd.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example opens a database file using command
// and function syntax.
REQUEST DBFCDX
PROCEDURE Main
USE Customer ALIAS Cust NEW
? Alias() // result: CUST
DbUseArea( .T., "DBFCDX" , "Orders", "Ord" )
? Alias() // result: ORD
CLOSE ALL
RETURN
http://www.xHarbour.com