Connecting to a Remote SAS Workspace Server

Goal

You want your application to connect to a remote SAS Workspace Server by using a method that enables you to use ADO objects exclusively. In addition, you want the SAS workspace to persist until the ADO Connection object is closed.
This recipe applies to the IOM provider. This recipe applies only to ADO. Sample code is included.
Note: The connection strings use the Data Source URI format. For more information, see What Is the Data Source URI Format?.
For an explanation of the properties used in the sample code, see IOM Provider Properties.

Implementation

Sample Connection Code for Common SAS 9.2 Server Configurations

The following table provides examples of connection strings for accessing common SAS 9.2 server configurations. In these examples, the SAS Workspace Server name is workspace.example.com and the port number is 8591.
Note: If you are not connecting to SAS 9.2 servers, then you cannot use the sample code in this topic.
Sample Code for Common SAS 9.2 Server Configurations
Server Configuration
Sample Code
Bridge with host authentication
Dim connectionString As String

connectionString = "Provider=SAS.IOMProvider.9.2; _
Data Source=iom-bridge://workspace.example.com:8591; _
User ID=jdoe;Password=734fi"
COM with host authentication
Dim connectionString As String

connectionString = "Provider=SAS.IOMProvider.9.2; _
Data Source=iom-com://workspace.example.com; _
User ID=jdoe;Password=734fi"
Bridge with IWA1
Dim connectionString As String

connectionString = "Provider=SAS.IOMProvider.9.2; _
Data Source=""iom://workspace.example.com:8591; _
Bridge;SECURITYPACKAGE=Negotiate"""
COM with IWA1
Dim connectionString As String

connectionString = "Provider=SAS.IOMProvider.9.2; _
Data Source=""iom://workspace.example.com; _
COM;SECURITYPACKAGE=Negotiate"""
1Extra quotation marks are required because of the semicolon used in the "Data Source" property value. If you are not using a connection string, then you do not need the extra quotation marks.

Sample Connection Code for SAS 9.2 Server Configurations That Include a SAS Metadata Server

The following table provides examples of connection strings for accessing common SAS 9.2 server configurations that include a SAS 9.2 Metadata Server. In these examples, the host name is metadata.example.com and the port number is 8561.
Note: If you are not connecting to SAS 9.2 servers, then you cannot use the sample code in this topic.
Sample Code for Common SAS 9.2 Server Configurations That Include a SAS Metadata Server
Server Configuration
Sample Code
Bridge with a logical server name defined in a SAS Metadata Server and host authentication
Dim connectionString As String

connectionString = "Provider=SAS.IOMProvider.9.2; _
Data Source=iom-name://Workspace Server - Logical Server Name; _
SAS Metadata Location=iom-bridge://metadata.example.com:8561; _
SAS Metadata User ID=metauserid;SAS Metadata Password=metapassword"
Bridge with a logical server name defined in a SAS Metadata Server and IWA1
Dim connectionString As String

connectionString = "Provider=SAS.IOMProvider.9.2; _
Data Source=iom-name://Workspace Server - Logical Server Name; _
SAS Metadata Location=""iom://metadata.example.com:8561; _
Bridge;SECURITYPACKAGE=Negotiate"""
If the user is not defined in the same authentication domain as the logical server name, then you must also include a line of code that specifies the user ID and password for the remote server.
User ID=myuserid;Password=mypassword;
Logical server name defined in a SAS Metadata Server that is configured via the SAS Integration Technologies configuration utility2
This type of connection does not require any additional metadata server information.
Dim connectionString As String

connectionString = "Provider=SAS.IOMProvider.9.2; _
Data Source=iom-name://Workspace Server - Logical Server Name"
1Extra quotation marks are required because of the semicolon used in the "Data Source" property value. If you are not using a connection string, then you do not need the extra quotation marks.
2The SAS Integration Technologies configuration utility (ITConfig) enables you to create a configuration file that contains information about how to access the metadata server. The provider uses that metadata server in order to resolve logical server names.

Sample Connection Code That Uses the Properties Collection

The following Visual Basic code works with all versions of SAS. In these examples, the SAS Workspace Server name is workspace.example.com and the port number is 8591.
Dim obConnection As New ADODB.Connection

obConnection.Provider = "sas.IOMProvider"
obConnection.Properties("Data Source") = "workspace"
obConnection.Properties("SAS Port") = 8591
obConnection.Properties("SAS Machine DNS Name") = "workspace.example.com"
obConnection.Properties("SAS Protocol") = SASObjectManager.ProtocolBridge
obConnection.Properties("User ID") = "jdoe"
obConnection.Properties("Password") = "734fi"
obConnection.Open 
Note: To use the sample code, you must reference the SASObjectManager Type Library in your Visual Basic project. SASObjectManager Type Library is installed with SAS Integration Technologies.