Mode Property

The Mode property on a Connection object sets or returns the available permissions for modifying data on a Connection.

currentMode = connection.Mode
connection.Mode = newMode
 

Remarks

The Mode property is used to set or return the access permissions in use by the provider on the current connection. The Mode property can only be set when the Connection object is closed.

Several of the ADO enumerated values for the mode settings imply that the using certain mode settings will prevent other applications from opening a connection to the file or table. Under the OLE DB provider for AS/400 and VSAM, these mode settings result in a file lock, but don't prevent other applications from opening a connection.

The value for the Mode can be one of the following enumerated values for ConnectModeEnum:

Enumeration Value Description
adModeUnknown 0 This value indicates that the permissions have not yet been set or cannot be determined.
adModeRead 1 This value indicates read-only permissions.
adModeWrite 2 This value indicates write-only permissions (not supported by the OLE DB provider for AS/400 and VSAM).
adModeReadWrite 3 This value indicates read/write permissions.
adModeShareDenyRead 4 This value prevents others from opening a connection with read permissions.
adModeShareDenyWrite 8 This value prevents others from opening a connection with write permissions.

Under the OLE DB provider for AS/400 and VSAM this mode setting is implemented as a file lock and doesn't result in excluding other applications from opening a connection. Other applications opening a connection will not receive an error, but the table or file will be locked preventing any changes from other applications.

adModeShareExclusive 0xc This value prevents others from opening a connection.

Under the OLE DB provider for AS/400 and VSAM this mode setting is implemented as a file lock and doesn't result in excluding other applications from opening a connection. Other applications opening a connection will not receive an error, but the table or file will be locked preventing any changes from other applications.

adModeShareDenyNone 0x10 This value prevents others from opening a connection with any permissions.

Under the OLE DB provider for AS/400 and VSAM this mode setting is implemented as a file lock and doesn't result in excluding other applications from opening a connection. Other applications opening a connection will not receive an error, but the table or file will be locked preventing any changes from other applications.


The Mode property defaults to adModeUnknown.