.NET Connection Strings for SugarCRM
SugarCRM is a customer relationship management (CRM) platform built to support sales, marketing, and customer service operations. Today, it stands as an enterprise-grade solution that offers robust functionality and AI-powered tools, along with the flexibility to build custom applications using its data.
In application development, connectivity is a critical factor. Many integration challenges can be addressed with dotConnect for SugarCRM, a powerful data provider that enables direct interaction with SugarCRM data without requiring additional client libraries or complex configurations.
To establish a successful connection to SugarCRM, you'll need a connection string that contains the necessary connection details. This guide explains the key components of a connection string and how to construct one effectively.
SugarCRM connection strings
The below code snippet describes how to create a new connection or connect to an existing SugarCRM account dynamically. Make sure to replace the placeholders with your actual SugarCRM credentials.
using Devart.Data.Sugar;
...
string Host = "https://your_company.sugaropencloud.eu";
string UserId = "admin";
string Password = "testpassword";
string LicenseKey = "**********";
string connectionString = $"Host={Server};User Id={UserId};Password={Password};License Key={LicenseKey}";
Main connection properties
The following table lists the valid names for values within the SugarCRM connection strings.
| Name | Description |
| Server | The login URL to the SugarCRM service. |
| User Id | The SugarCRM login account to use. |
| Password | The password for the SugarCRM login account. |
| License Key | The license key that you should specify in the connection string. |
Additional connection properties
The table below provides the valid names for values used in SugarCRM connection strings.
| Name | Description |
| Connection Lifetime | When a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span (in seconds) exceeds the value specified by Connection Lifetime. The default value is 0 (connection always returns to the pool). |
| Connect Timeout -or- Connection Timeout | The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error. The default value is 15. |
| Default Command Timeout | The time in seconds to wait while trying to execute a command before terminating the attempt and generating an error. A value of 0 indicates no limit. |
| Initialization Command | Specifies a data source-specific command that should be executed immediately after establishing the connection. |
| Max Pool Size | The maximum number of connections allowed in the pool. Setting the Max Pool Size value of the ConnectionString can affect performance. The default value is 100. |
| Min Pool Size | The minimum number of connections allowed in the pool. The default value is 0. |
| Persist Security Info | Indicates if security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open state. |
| Platform | The SugarCRM platform you should specify when connecting to SugarCRM. You can read more about SugarCRM platforms in the SugarCRM developer blog. |
| Pooling | If true, by default, the SugarConnection object is drawn from the appropriate pool or is created and added to the relevant pool. |
| Proxy Host | The host name 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. |
| Run Once Command | A command to execute when the connection is opened for the first time, and not executed when the connection is taken from the pool. |
| Readonly | Determines whether the connection is read-only (allows only SELECT statements). |
| Use Email Relationship | Determines how SugarCRM email-related data is processed - via the email1, email_addresses_non_primary, invalid_email, email_opt_out, and email_and_name1 fields or via a single email field, storing a JSON array with emails and all their settings. |
| UTC Dates | Indicates whether all the datetime values retrieved from the data source are returned as UTC values or converted to local time, and whether date values, specified on the application side (for example, in SQL statements), are considered UTC or local. The default value is false. |
Conclusion
When developing applications in C# and .NET that use SugarCRM as a data source, one of the primary tasks is to establish a fast, stable, and reliable connection to that data.
This article provides a sample connection script and explains the values used in connection strings. With this information, you'll be able to construct connection strings to use when building applications in Visual Studio. You can also download a fully functional free trial of dotConnect for SugarCRM and evaluate its work under your actual workload.