Connecting to a Remote SAS/SHARE Server

Goal

You want your application to connect to a remote SAS/SHARE server.
This recipe applies to the SAS/SHARE provider. Sample code for ADO is included.

ADO Implementation

The following Visual Basic code shows you how to specify the remote server information. This sample uses the Connection object Properties collection to specify individual property values. The server ID is shr1.
Dim obConnection As New ADODB.Connection

obConnection.Provider = "sas.ShareProvider"
obConnection.Properties("Data Source") = "shr1"
obConnection.Properties("Location") = "ShareServer.example.com"
obConnection.Properties("User ID") = "jdoe"
obConnection.Properties("Password") = "djru7"
obConnection.Open
Connection information can also be submitted in a single connection string:
obConnection.Open "Provider=sas.ShareProvider;Data Source=shr1; _
                   Location=ShareServer.example.com;User ID=jdoe; _
                   Password = djru7"
	 
Note: For a step-by-step example and answers to questions that are frequently asked about setting up a SAS/SHARE server, see "SAS/SHARE: Learning to Use" in the SAS/SHARE User's Guide.
For an explanation of the properties used in the sample code, see SAS/SHARE Provider Properties.

OLE DB Implementation

OLE DB requires that you use a data source object to connect to a remote SAS/SHARE server. The following table shows how the ADO connection properties that were previously discussed correspond to the OLE DB data source initialization properties.
OLE DB Data Source Initialization Properties
OLE DB Property Set
OLE DB Property ID
Corresponding ADO Property
DBPROPSET_DBINIT
DBPROP_INIT_DATASOURCE
"Data Source"
DBPROPSET_DBINIT
DBPROP_INIT_LOCATION
"Location"
DBPROPSET_DBINIT
DBPROP_AUTH_USERID
"User ID"
DBPROPSET_DBINIT
DBPROP_AUTH_PASSWORD
"Password"
The OLE DB data source initialization properties use the same syntax as their ADO counterparts. As shown in ADO Implementation, the ADO property values are represented as character strings. In OLE DB, which has only C and C++ language bindings, these property values are implemented as variant type VT_BSTR.