Resources

Reading a SAS/ACCESS Data Set

In this recipe, you learn how to use the IOM Data Provider to access third-party data stores that are available through your licensed SAS/ACCESS engines. Sample code for the ADO recipe is included.

Applies to: SAS IOM Data Provider
Implement using: ADO or OLE DB

Overview

You can use the SAS IOM Data Provider to access third-party data stores that are available through your licensed SAS/ACCESS engines. The following Visual Basic code fragment uses an ADO Command object named cmd to assign a libref and an ADO Recordset object named rs to open a data set.

cmd.ActiveConnection = obConnection
cmd.CommandType = adCmdText
cmd.CommandText = "libname mylib oracle user=todd password=king path=oraclev7;"
cmd.Execute
rs.Open "mylib.dept", obConnection, adOpenStatic, adLockReadOnly, adCmdTableDirect 
 

Note: The syntax that you will use in your LIBNAME statement depends on the SAS/ACCESS engine that you are using and on your operating environment. SAS/ACCESS engines are implemented differently in different operating environments. See your DBMS-specific documentation for more information.

Note: For more information about how to open a Connection object, see Opening an ADO Connection Object.


Details

As illustrated for ADO in the Visual Basic code shown previously, there are two steps that you must perform to access the third-party data stores:

  1. Execute a LIBNAME statement that specifies the SAS/ACCESS engine name. You can do this using either the ADO Command object, the OLE DB Command object, or the SAS IOM IDataService::AssignLibref method.
  2. Read the SAS/ACCESS data set using either ADO Recordset object methods or OLE DB rowset methods; both must be opened for read-only access.
    • In ADO, set the Recordset object's LockType property to adLockReadOnly.
    • In OLE DB, set the DBPROP_IRowsetChange property to False.