.NET Connection String for Salesforce
Salesforce connection strings provide the parameters necessary to establish a successful connection to Salesforce, ensuring proper communication between the application and the service.
This guide will explain the key components of Salesforce connection strings, their construction, and best usage practices.
Salesforce connection strings
The following code snippet describes how to create or connect to an existing Salesforce account dynamically:
using Devart.Data.Salesforce; ... SalesforceConnection conn = new SalesforceConnection(); conn.ConnectionString = @"Server=login.salesforce.com;UserId=name@company.com;Password=mypassword;SecurityToken=YourToken;";
Main connection properties
The following table lists the valid names for main values within the Salesforce connection strings.
Name | Description |
Authentication Type | The authentication method for connecting to Salesforce, such as UserNamePassword, AccessRefreshToken, SessionId, etc. For more information, refer to How to get a security token from Salesforce. |
Host | The Salesforce.com or Database.com login URL, such as login.salesforce.com, login.database.com, test.salesforce.com, etc. |
User ID -or- User | The Salesforce login account. |
Password | The password for the account. |
Refresh Token | The Salesforce OAuth 2.0 refresh token used for the OAuth Refresh Token authentication. |
Security Token | The automatically generated key used to log in to Salesforce from untrusted networks. |
License Key | The license key. |
Additional connection properties
The table below lists valid names for additional parameters in Salesforce connection strings to ensure the most accurate connection.
Name | Description |
Client ID | The Consumer Key from the connected app definition. Is used for the OAuth Refresh Token authentication. |
Client Secret | The Consumer Secret from the connected app definition. Is used for the OAuth Refresh Token authentication. |
Session ID | The Salesforce session ID for the session ID authorization. |
Batch Size | The number of records returned by the service at once. The default value is 500; the minimum value is 200, and the maximum value is 2,000. |
Cache All | Allows creating a cache for all tables when connecting. Data is cached only when it is queried. |
Connection Lifetime | Compares the connection creation time with the current time when the connection is returned to the pool. The connection is destroyed if that period (in seconds) exceeds the value specified as Connection Lifetime. The default value is 0 (connections always return to the pool). |
Connect Timeout -or- Connection Timeout | The duration of time (in seconds) to wait for connecting to the server before terminating the attempt and generating an error. The default value is 15. |
Data Cache | The path to the data cache database file. |
Default Refresh Interval | Determines the default value of the interval (in seconds) between data cache refreshing. The default value is 3600 (one hour). |
Deferred Login | Determines whether to delay establishing an actual connection to Salesforce until some data not present in the local cache is queried or modified. |
Include Deleted | Determines whether to include the deleted records (from the Salesforce recycled bin) in the SELECT query results. |
Initialization Command | Specifies database-specific commands that should be executed immediately after establishing the connection. |
Max Pool Size | The maximum number of connections allowed in the pool. The default value is 100. Note: Changing the value can affect performance. |
Metadata Cache | The path to the metadata cache database file. |
Min Pool Size | The minimum number of connections allowed in the pool. The default value is 0. |
Organization ID | A unique identifier for the Salesforce organization to which the account belongs. |
Persist Security Info | Indicates if security-sensitive information, such as passwords, is not returned as part of the connection if the connection is open or has ever been open. |
Pooling | Retrieves the SalesforceConnection object from the appropriate pool or creates and adds it to the appropriate pool. The default value is true. |
Proxy Host | The hostname or IP address of the proxy server. |
Proxy Password | The password for the proxy server account. |
Proxy Port | The port number of the proxy server. The default value is 3128. |
Proxy User | The proxy server account name. |
Refresh Metadata | Specifies whether to refresh Salesforce metadata each time on opening the connection. |
System Objects | Specifies whether the Salesforce objects system fields should be accessible. The default value is false. |
Trigger Auto Response Email | Specifies whether to trigger auto-response rules or not. The default value is false. |
Trigger Other Email | Specifies whether to trigger emails outside the organization or not. The default value is false. |
Trigger User Email | Specifies whether to trigger emails sent to users in the organization. The default value is false. |
Update Mru | Specifies whether to update the list of most recently used items. |
Upgrade Cache | Determines whether to upgrade the local cache database or to throw an exception when dotConnect for Salesforce uses a newer cache structure or newer version of Salesforce API and discovers old incompatible cache for the opening connection. |
Use Assignment Rules | Determines whether to use assignment rules when inserting or updating data. The default value is false. |
UTC Dates | Indicates whether all datetime values retrieved from Salesforce are returned as UTC values or converted to local time and whether date values specified on the application side (like in SQL statements) are considered UTC or local. The default value is false. |
Conclusion
Salesforce connection strings are crucial in connecting applications to Salesforce, ensuring smooth communication between the application and its back-end database engine. This article provides detailed guides on configuring Salesforce connection strings with various parameters and implementation methods.
dotConnect for Salesforce is an essential tool that simplifies establishing connections, thus allowing users to build high-performance applications based on Salesforce as the data source. To experience the full potential of dotConnect for Salesforce, download the free trial and see how it handles your specific workload!