Click or drag to resize

SetExclusive Function

Return and optionally change the setting that determines whether to open database files in exclusive or shared mode.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.19
Request Example View Source

Return Value

Type: Logic
If lNewSetting is not specified, SetExclusive() returns the current setting.
If lNewSetting is specified, the previous setting is returned.
SetExclusive() determines whether a USE command specified without the EXCLUSIVE or SHARED clause automatically opens database, memo, and index files as EXCLUSIVE. When database files are opened as EXCLUSIVE, other users cannot use them until they are closed. In this mode, file and record locks are unnecessary. When TRUE is specified, all database and associated files open in a nonshared (exclusive) mode unless the USE command is specified with the SHARED clause.
Use this only for operations that absolutely require exclusive use of a database file, such as PACK, REINDEX, and ZAP. When FALSE is specified, all files are open in shared mode unless the USE command is specified with the EXCLUSIVE clause. Do not use SetExclusive() to control access by other users to records and files. You can control access programmatically using RLock() and FLock(). SetExclusive() is a compatibility function and not recommended.
It is superseded by the EXCLUSIVE and SHARED clauses of the USE command.
Tip Tip
Error handling:
Attempting to use a database file already opened as exclusive by another user generates a runtime error and sets NetErr() to TRUE.
After control returns to the point of error, you can test NetErr() to determine whether the USE command failed.