In this recipe, you learn how to set permissions on your data source.
Applies to: | All SAS Data Providers |
Implement using: | ADO or OLE DB |
When you are writing to the ADO interface, you use the Connection object's Mode property to dictate the available permissions for modifying data. The Mode property values can also affect which lock type is used on opened recordsets. For example, you could use the following Visual Basic code to set read-only access before the connection is opened. Recordsets that are opened using that connection will use the adLockReadOnly lock type, even if you request a different lock type.
obConnection.Mode = adModeRead obConnection.Open
Note: For more information about lock types, see Implementing a Locking Strategy and Supported ADO Cursor and Lock Type Combinations.
When you are writing to the OLE DB interface, you set a particular DBPROP_INIT_MODE flag to get the same results as setting the ADO Connection object's Mode property. See OLE DB Details for more information.
The SAS Data Providers support the following four values for the ADO Connection object's Mode property:
The default value for the Mode property is adModeReadWrite in conjunction with adModeShareDenyNone. The following table provides additional information about how the SAS Data Providers handle Mode property values:
Mode Set | Mode Used | Notes |
---|---|---|
adModeShareDenyRead, adModeShareDenyWrite, or adModeShareDenyExclusive | adModeShareDenyNone | It is not possible for a client to prevent other clients from connecting to a server. |
adModeWrite | adModeReadWrite | It is not possible to open a connection that is limited only to write operations; reading data is always supported on an open connection. |
adModeRead | adModeRead | If read-only access is set before the connection is opened, recordsets that are opened using the connection will use the adLockReadOnly lock type, regardless of any other lock type that you may have requested. |
The following table lists the one-to-one correspondence between the values of the ADO Connection object's ConnectModeEnum constants (the Mode property names) and the bit masks defined for the OLE DB DBPROP_INIT_MODE data source property.
ConnectModeEnum Constant | DBPROP_INIT_MODE Bit Mask |
---|---|
adModeRead | DB_MODE_READ |
adModeWrite | DB_MODE_WRITE |
adModeReadWrite | DB_MODE_READWRITE |
adModeShareDenyRead | DB_MODE_SHARE_DENY_READ |
adModeShareDenyWrite | DB_MODE_SHARE_DENY_WRITE |
adModeShareDenyExclusive | DB_MODE_SHARE_DENY_EXCLUSIVE |
adModeShareDenyNone | DB_MODE_SHARE_DENY_NONE |
adModeUnknown | 0 |
Setting a particular DBPROP_INIT_MODE bit mask value has the same effect as setting the ADO Connection object's Mode property to the corresponding ConnectModeEnum value, as shown in the following table:
DBPROP_INIT_MODE Bit Mask Set | DBPROP_INIT_MODE Bit Mask Used | Notes |
---|---|---|
DB_MODE_SHARE_DENY_READ, DB_MODE_SHARE_DENY_WRITE, or DB_MODE_SHARE_DENY_EXCLUSIVE | DB_MODE_SHARE_DENY_NONE | It is not possible for a client to prevent other clients from connecting to a server. |
DB_MODE_WRITE | DB_MODE_READWRITE | It is not possible to open a connection that is limited only to write operations; reading data is always supported. |
DB_MODE_READ | DB_MODE_READ | Use of DB_MODE_READ bit without the DB_MODE_WRITE bit restricts open rowsets to read-only access. Read-only rowsets do not implement the IRowsetChange and IRowsetUpdate interfaces. |