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
Dim obSAS As SAS.Workspace
Dim obOF As New SASObjectManager.ObjectFactory
Dim obOK As New SASObjectManager.ObjectKeeper
Dim obServerDef As New SASObjectManager.ServerDef
' Use ServerDef attributes to identify the remote server.
obServerDef.Protocol = ProtocolBridge
obServerDef.MachineDNSName = "workspace.example.com"
obServerDef.Port = 8591
' Create a workspace on the identified remote server.
Set obSAS = obOF.CreateObjectByServer("MyServer", True, obServerDef, "johnd", "xyz")
' Add the new workspace object to the ObjectKeeper.
Call obOK.AddObject(1, "WorkspaceObject", obSAS)
' Open a connection to the workspace by using its UniqueIdentifier, which is generated automatically.
obConnection.Open "Provider=sas.iomprovider.9.2; Data Source=iom-id://" & obSAS.UniqueIdentifier
:
:
:
obConnection.Close
' Remove the workspace object from the ObjectKeeper.
Call obOK.RemoveObject(obSAS)