Dynamics 365 ODBC connection string parameters

The following table describes the key connection string parameters for connecting to Dynamics 365 via the ODBC driver.

Server configuration

Parameter Description
Authentication Specifies the authentication method used to connect to Dynamics 365. Available values:
  • OAuth – (Default) The OAuth 2.0 authentication.
  • User ID and Password – The password-based authentication.
Client Id Specifies the Dynamics 365 client ID, required for OAuth 2.0 authentication.
Client Secret Specifies the Dynamics 365 client secret, required for OAuth 2.0 authentication.
Password Specifies the Dynamics 365 password, required for password-based authentication.
Refresh Token Specifies the OAuth 2.0 refresh token, required for OAuth 2.0 authentication.
Server Specifies the Dynamics 365 server URL.
User ID Specifies the Dynamics 365 username, required for password-based authentication.

Proxy settings

Parameter Description
Proxy Password Specifies the password required for proxy authentication.
Proxy Port Specifies the port number for the proxy server.
Proxy Server Specifies the hostname or IP address of the proxy server.
Proxy User Specifies the username required for proxy authentication.

Advanced settings

Parameter Description
AllowNullStringsInMetadata Allows metadata retrieval even when some parameters contain NULL values, ensuring compatibility with third-party tools that pass NULL. The default value is True.
Cache Metadata Configures metadata caching. Available values:
  • False – Caching is disabled.
  • Hour – Cached metadata is reset every hour.
  • Day – (Default) Cached metadata is reset daily (every 24 hours).
  • Month – Cached metadata is reset monthly.
  • True – Metadata caching is permanent until the driver is unloaded.
Connection Timeout Sets the timeout (in seconds) for establishing a connection. The default value is 60.
EmptyStringsAsNullInMetadata Converts empty strings to NULL when retrieving data. The default value is True.
ODBC Behavior Specifies the ODBC specification version the driver must conform to, based on the expectations of a third-party tool.
Typically, the driver’s behavior is controlled by setting the SQL_ATTR_ODBC_VERSION attribute via the SQLSetEnvAttr function. However, some third-party tools expect the driver to behave according to ODBC 2.x standards, but either fail to set this attribute or pass an incorrect value.
In such cases, you can explicitly define the required behavior in the connection string using the ODBC Behavior parameter. Available values:
  • 0 – (Default) Uses the default behavior as determined by the third-party tool.
  • 2 – Forces the driver to use ODBC 2.x behavior.
  • 3 – Forces the driver to use ODBC 3.x behavior.
Query Timeout Sets the timeout (in seconds) for query execution. The default value is 60.
RegionalDateTimeSettings Enables local regional settings for converting dates and times to strings. The default value is False.
RegionalNumberSettings Enables local regional settings for converting numbers to strings. The default value is False.
ReturnForeignKeys Specifies whether to include foreign keys in metadata queries, which may impact performance. The default value is False.
String Types Specifies the type of string data returned. Available values:
  • Default – (Default) The driver determines the appropriate string types.
  • Ansi – Returns string data as SQL_CHAR, SQL_VARCHAR, and SQL_LONGVARCHAR.
  • Unicode – Returns string data as SQL_WCHAR, SQL_WVARCHAR, and SQL_WLONGVARCHAR.
UTC Dates Specifies whether datetime values should be returned as UTC or converted to local time. The default value is False.

Sample connection string

The following sample Dynamics 365 ODBC connection string uses password-based authentication.

DRIVER={Devart ODBC Driver for Dynamics 365};Server=https://dynamicsaccount.crm.dynamics.com;User ID=your_dynamics_username;Password=your_dynamics_password