DataConnector | ComponentOne
ADO.NET provider for Salesforce / Creating Connection
In This Topic
    Creating Connection
    In This Topic

    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.

    CS
    Copy Code
    //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:

    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".