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 |
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.
Note: If your IOM server is an LDAP server, then you must specify the server information in this way.
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 |
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:
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."