In this recipe, you learn how to open a data set that requires a password. Sample code for the ADO recipe is included.
Applies to: | SAS Local Data Provider, SAS/SHARE Data Provider, SAS IOM Data Provider |
Implement using: | ADO or OLE DB |
If you need to specify a password to open a data set, use the appropriate customized rowset password property. The following sample code uses the ADO "SAS Read Password" property to open a read-protected data set. Assume that the connection is already open.
Note: For information about how to open a Connection object, see Opening an ADO Connection Object.
obRecordset.ActiveConnection = obConnection obRecordset.Properties("SAS Read Password") = "password" obRecordset.Open source, , adOpenStatic, adLockReadOnly, adCmdTableDirect
Note: The second parameter must remain empty, as shown in the code fragment.
SAS supports three types of data set passwords: READ, WRITE, and ALTER. The SAS Data Providers implement three properties that correspond to each of the password types.
The following table lists the ADO Recordset property names and their corresponding OLE DB property names. The OLE DB properties are part of the DBPROP_SAS_ROWSET customized property set (see OLE DB Properties: Group Index).
ADO Recordset Property Name | OLE DB Rowset Property Name | SAS Data Set Property |
---|---|---|
SAS Read Password | DBPROP_SAS_READPASSWORD | READ= |
SAS Write Password | DBPROP_SAS_WRITEPASSWORD | WRITE= |
SAS Alter Password | DBPROP_SAS_ALTERPASSWORD | ALTER= |
Note: See SAS 9.1 Language Reference: Concepts for complete information about SAS data set passwords.