Setting up a Connection to ODBC in Delphi Using Devart ODBC Driver
This guide will walk you through the steps of setting up a connection to an ODBC driver in Delphi. We'll use ODBC Driver for Salesforce as an example.
Prerequisites:
- Devart ODBC Driver for Salesforce installed on your machine.
- A Salesforce account for connection.
- Delphi IDE (Integrated Development Environment) for project development.
Step 1: Download and Install the ODBC Driver for Salesforce
You can refer to detailed configuration instructions
here.
After configuring the DSN, you can click on the Test Connection button to ensure the settings are correct.
Step 3: Create a New Delphi Project
Open Delphi IDE:
- Launch the Delphi IDE to create a new project.
Add Components:
- Create a small Delphi application that includes the necessary components:
Use the following code to configure the TUniConnection component to connect via ODBC:
- uses ODBCUniProvider;
- ...
- UniConnection.ProviderName := 'ODBC';
- UniConnection.Server := 'Devart Salesforce Driver';
In this case, the Server property is set to the DSN you created in Step 2, specifically "Devart Salesforce Driver".
Alternatively, you can use the ConnectString property to define the ODBC connection without explicitly using the DSN. Here’s how you can configure it for Salesforce:
- UniConnection.ConnectString := 'Provider Name=ODBC;Server="DRIVER={Devart ODBC Driver for Salesforce};Data Source=login.salesforce.com;User ID=;Password=;Security Token="';
Step 5: Write the SQL Queries
- AccountQuery.SQL.Text := 'Select Id, Name, BillingStreet, BillingState, WebSite From Account';
- OpportunityQuery.SQL.Text := 'Select Name, StageName, Amount, Type, Description From Opportunity Where AccountId = :Id';

Note that in both queries we did not use all the fields of the Account and Opportunity objects, but only those, which are needed for the demonstration. In addition, to implement the master-detail connection, we added the appropriate Where clause.
Set Up Master-Detail Relationship:
- AccountDataSource.DataSet := AccountQuery;
- OpportunityDataSource.DataSet := OpportunityQuery;
- OpportunityQuery.MasterSource := AccountDataSource;
Step 7: Open the Queries to Fetch Data
Execute the Queries:
- AccountQuery.Open;
- OpportunityQuery.Open;
Step 8: Review the Result
Below is a sample screenshot showing the result of the connection:
Related Articles
Setting up a Connection to Power BI Online Using Devart ODBC Driver
In this guide, we will walk you through the process of setting up a connection to Power BI Online using the Devart ODBC Driver. This involves creating a DSN connection, setting up an on-premises gateway, and verifying Power BI report settings. Step ...
Setting up a Connection to QuickBooks Desktop Using Devart ODBC Driver
This knowledge base article provides step-by-step instructions on how to set up a connection to QuickBooks Desktop using the Devart ODBC Driver. Following these steps will help you successfully connect to QuickBooks Desktop and retrieve your ...
Setting Up MongoDB Atlas and Connecting via Devart ODBC Driver
This article will guide you through the process of setting up MongoDB Atlas, creating a cluster, configuring access, obtaining the connection string, and connecting to MongoDB Atlas using the Devart ODBC Driver for MongoDB. 1. Creating a Cluster in ...
How to Configure Devart ODBC Drivers for Optimal Performance
To ensure optimal performance when using Devart ODBC drivers, it's recommended to fine-tune several key parameters: Connection Timeout — Set an appropriate timeout to avoid long waits on unresponsive connections. Data Fetching Size — Adjust the ...
Guide: Configuring ODBC Driver in Azure Data Factory
This guide walks you through the steps of setting up and using an ODBC driver in Azure Data Factory (ADF) for seamless data integration. By following this guide, you will be able to configure an ODBC driver, create a Linked Service, and define an ...