[]
        
(Showing Draft Content)

Creating Connection

To establish a connection to a Salesforce data source, the ADO.NET Provider can be used through the C1SalesforceConnection class. This class requires a connection string to be provided as an argument, which can be created in either of the following ways:

The following code shows how to use the C1SalesforceConnectionStringBuilder class to configure the connection string for Salesforce, which can then be consumed by the C1SalesforceConnection class to establish a connection to the Salesforce server. Through that connection, the data source can be queried.

//Salesforce service URL
const string GCSalesforceServerConnectionString = @"Username=**********;Password=***********;Security Token=************;
                                                OAuth Client Id=***********; 
                                                OAuth Client Secret=***************; 
                                                OAuth Token Endpoint=https://ap16.salesforce.com/services/oauth2/token; 
                                                Url=https://ap16.salesforce.com/services/data/v45.0";
// Configure connection string            
C1SalesforceConnectionStringBuilder builder = new C1SalesforceConnectionStringBuilder();
builder.ConnectionString = $@"{GCSalesforceServerConnectionString}";
//Setup Connection
C1SalesforceConnection con = new C1SalesforceConnection(builder.ConnectionString);

In Salesforce, the ApiVersion property in the connection string specifies the API version of Salesforce to be used. There are two ways to specify the ApiVersion:

  • Specifying in the URL: If the ApiVersion is provided in the URL, such as "Url=https://ap16.salesforce.com/services/data/v45.0", the settings of the ApiVersion in the connection string will be ignored.
  • Not specifying in the URL: If the ApiVersion is not included in the URL, you can set it in the connection string using the following format: connectionString = "Url=https://ap16.salesforce.com/services/data/; Api Version = 43". Ensure that the specified ApiVersion is not lower than 42, as attempting to set a value lower than this will result in an exception.

type=note

Note: The properties of C1SalesforceConnectionStringBuilder can be used to setup the connection keys when passed as connection strings. The connection key will be the corresponding property with added space character. For example, "UseCache" will be used as "Use Cache".