Resources

Connecting to a Remote SAS/SHARE Server

In this recipe, you learn how to use either ADO or OLE DB to connect to a remote SAS/SHARE server. This recipe also lists the minimum required information and includes sample code for the ADO connection.

Applies to: SAS/SHARE Data Provider
Implement using: ADO or OLE DB

Overview

To open an ADO connection against a remote SAS/SHARE server you must specify:

You can supply this information by using the Visual Basic code in the following example:


  Dim obConnection As ADODB.Connection

  Set obConnection = New ADODB.Connection
    
  obConnection.Provider = "sas.ShareProvider.1"
  obConnection.Properties("Data Source") = "shr1"
  obConnection.Properties("Location") = "lambchop.unx.sas.com"
  obConnection.Properties("User ID") = "fred"
  obConnection.Properties("Password") = "banana"
  obConnection.Open
  

This information also can be entered in a single connection string:


  obConnection.Open "Provider=sas.ShareProvider.1;Data Source=shr1;Location=lambchop.unx.sas.com;UserID=fred;Password = banana"
	   

If the server requires a password in order to establish a connection, you can specify the password as the value of the "SAS Server Access Password" property:


  obConnection.Properties("SAS Server Access Password") = "apple"
	

Note: For more information about how to open a Connection object, see Opening an ADO Connection Object.

Note: For a step-by-step example and answers to questions frequently asked about setting up a SAS/SHARE server, see "SAS/SHARE: Learning to Use" in the SAS/SHARE 9.1 User's Guide.

For an explanation of the ADO implementation, see ADO Details. For information about the OLE DB implementation, see OLE DB Details.


ADO Details

To use the SAS/SHARE Data Provider to open a Connection object, you must specify the following information:

If your server requires users to authenticate themselves when they make a connection, you must also provide the following information:

These values are usually the same as the user's login information for the remote host on which the server resides.


OLE DB Details

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.

ADO Connection Property OLE DB Property Set OLE DB Property ID
Data Source DBPROPSET_DBINIT DBPROP_INIT_DATASOURCE
Location DBPROPSET_DBINIT DBPROP_INIT_LOCATION
User ID DBPROPSET_DBINIT DBPROP_AUTH_USERID
Password DBPROPSET_DBINIT DBPROP_AUTH_PASSWORD
SAS Server Access Password DBPROPSET_SAS_DBINIT DBPROP_SAS_INIT_SERVERPASSWORD

The OLE DB data source initialization properties use the same syntax as their ADO counterparts. As shown in the sample Visual Basic code at the beginning of this topic, the ADO property values are represented as character strings; in OLE DB, which only has C and C++ language bindings, these property values are implemented as variant type VT_BSTR.