Reusing an Existing IOM Workspace

Goal

You want your application to reuse an existing IOM Workspace.
This recipe applies to the IOM provider. This recipe applies only to ADO. Sample code is included.
Note: To use the sample code, you must reference the SAS Integrated Object Model (IOM) Library in your Visual Basic project.

Implementation

You can use the "SAS Workspace ID" property to associate a running SAS workspace object with an ADO Connection object. "SAS Workspace ID" is a customized connection property. It indicates that you want to use a workspace that you have already created. You set this property on a Connection object after you set the Connection object Provider property and before you invoke the Open method. The following Visual Basic code shows you how to use this method:
Dim obConnection As New ADODB.Connection

obConnection.Provider = "sas.IOMProvider"
obConnection.Properties("SAS Workspace ID") = obSAS.UniqueIdentifier 
' Set other connection properties as needed.
obConnection.Open
In the sample code, obSAS is a SAS.Workspace object that has been previously created. The workspace provides the same set of resources and facilities as an interactive or batch SAS session. The Workspace Object class is part of SAS Integration Technologies. The UniqueIdentifier workspace property instructs the IOM provider to look up an existing workspace and to establish communication with it.
Note: For information about working with object variables and creating a workspace, see the SAS Integration Technologies: Windows Client Developer's Guide.