Resources

Connecting to a Remote IOM Server

In this recipe, you learn how to establish a connection to a remote SAS IOM Server.

Applies to: SAS IOM Data Provider
Implement using: ADO

Overview

To connect to a remote IOM Server, you specify the remote server information and then you use the Connection object's Open method to establish a connection. There are two methods for establishing the connection. Both require similar server information. Choose the method that best suits your needs.


Method 1: Setting Properties on the ADO Connection Object

The following Visual Basic code illustrates how to connect to a remote IOM server by setting properties on an ADO Connection object. When an ADO Connection object is opened using these properties, a new SAS workspace is created. The workspace will persist until the ADO Connection object is closed.

' Constants defined in SASWorkspaceManager Type Library.
const ProtocolCom = 0
const ProtocolCorba = 1
const ProtocolBridge = 2

' Constants from OLEDB.h
const DBPROPVAL_DST_TDP = 1
const DBPROPVAL_DST_MDP = 2

Dim obConnection As ADODB.Connection

Set obConnection = New ADODB.Connection

obConnection.Provider = "sas.IOMProvider.9"
' OPTIONAL: This sets the "SAS Server Type" property to its default value.
obConnection.Properties("SAS Server Type") = DBPROPVAL_DST_TDP
obConnection.Properties("Data Source") = "MyServerName"
obConnection.Properties("SAS Port") = 1359
obConnection.Properties("SAS Machine DNS Name") = "lambchop.unx.sas.com"
obConnection.Properties("SAS Protocol") = ProtocolBridge
obConnection.Properties("User ID") = "fred"
obConnection.Properties("Password") = "banana"
obConnection.Open 

The following table lists the relevant Connection object properties. Some requirements are server-specific.

Property Value Required for a remote server?
Data Source Any convenient logical name for the server being accessed. Yes
SAS Machine DNS Name Network DNS name of the server or the IP address of the server. Yes
User ID User ID to authenticate against the server. Might be required by server.
Password Password to use with the user ID in authenticating against the server. Might be required by server.
SAS Port TCP/IP port number of the remote server. Must specify either this property or the "Service Name" property.
SAS Service Name Logical reference to the port associated with a remote server. Yes, unless "SAS Port" is specified.
SAS Protocol IOM protocol to use when connecting to the remote server. Yes


Method 2: Creating a SAS Workspace with the SAS Workspace Manager

To create a SAS Workspace with the SAS Workspace Manager, you must reference these type libraries in your Visual Basic project:

Note: See Minimum System Requirements for the SAS Data Providers for supported versions of MDAC. The SAS Integrated Object Model (IOM) Type Library and SASWorkspaceManager Type Library are installed with the Integration Technologies client.

The following Visual Basic code performs these tasks:

  1. Specifies a remote server by instantiating a SAS Server Definition (ServerDef) object and setting its attributes.
  2. Invokes the SAS Workspace Manager's CreateWorkspaceByServer method to create a workspace on the remote server. The ServerDef object is passed in as a parameter, along with the data source name, user ID and password. After the workspace is created, the workspace is referred to by its UniqueIdentifier.
  3. Opens the ADO Connection object, setting the "SAS Workspace ID" property to the SAS workspace's UniqueIdentifier. This step makes the connection to the remote server.
  4. Closes both the SAS workspace and the Connection object.
Dim obConnection As ADODB.Connection
Dim obSAS As SAS.Workspace
Dim obWM As SASWorkspaceManager.WorkspaceManager
Dim obServerDef As SASWorkspaceManager.ServerDef
Dim errorString As String

Set obConnection = New ADODB.Connection
Set obWM = New SASWorkspaceManager.WorkspaceManager
Set obServerDef = New SASWorkspaceManager.ServerDef

' Server Definition attributes specify the remote server
obServerDef.Protocol = ProtocolBridge
obServerDef.MachineDNSName = "lambchop.unx.sas.com"
obServerDef.Port = 1359
        
' Create a workspace on the remote server
Set obSAS = obWM.Workspaces.CreateWorkspaceByServer("MyServerName", VisibilityProcess, obServerDef, "fred", "banana", errorString)

' Open a connection to the workspace
obConnection.Open "Provider=sas.iomprovider.9; SAS Workspace ID=" & obSAS.UniqueIdentifier
:
:
:

obConnection.Close
obSAS.Close

For more information about SAS Workspace Manager methods as well as the "SAS Machine DNS Name," "SAS Protocol," and "SAS Service Name" properties, access the documentation for SAS Integration Technologies, which is located at which is located at support.sas.com/rnd/itech/library/library9.html. In the Developer's Guide under "Developing Windows Clients," see the section entitled "Using the Workspace Manager."