We are proud to share our inclusion in the 2024 Gartner Magic Quadrant for Data Integration Tools. We believe this recognition reflects the differentiated business outcomes CData delivers to our customers.
Get the Report →Easily Integrate Salesforce Data Cloud Data in Lazarus Pascal IDE
Learn how to easily integrate live Salesforce Data Cloud data in Lazarus Pascal IDE using the CData ODBC Driver for real-time insights.
Lazarus Pascal IDE is a powerful, free, open-source development environment for building cross-platform applications. With the CData ODBC Driver for Salesforce Data Cloud, you can seamlessly integrate and query live Salesforce Data Cloud data, bringing real-time insights within your Lazarus Pascal IDE applications to enhance reporting, dashboards, and workflows.
This guide provides a comprehensive walkthrough, from setting up the connection to leveraging live Salesforce Data Cloud in Lazarus Pascal IDE. Whether you're building reports, dashboards, or complex workflows, you'll gain the tools to unlock real-time insights and functionality within your applications.
Overview
Here is an overview of the steps:
- Configure the DSN for Salesforce Data Cloud data in the CData ODBC Driver for Salesforce Data Cloud with the necessary connection properties.
- Set up the ODBC connection in Lazarus by configuring the TSQLConnector, TSQLQuery, TDataSource, and TDBGrid components with the required details.
- Test the connection to Salesforce Data Cloud data by writing sample code on the Main form.
- Compile and run the application to verify the successful integration and display of live Salesforce Data Cloud data.
Prerequisites
Before starting, ensure you have the following:
- Lazarus IDE (version 3.4 recommended). Download from here.
- CData ODBC Driver for Salesforce Data Cloud. Download and try the latest version from here.
Configure the Salesforce Data Cloud DSN Using the CData ODBC Driver
To start, configure the DSN (Data Source Name) for Salesforce Data Cloud data in your system using the CData ODBC Driver for Salesforce Data Cloud. Download and install a 30-day free trial with all the features from here.
Once installed, launch the ODBC Data Source Administrator:
- On Windows: Search for ODBC Data Source Administrator in the Start menu and open the application.
- On Mac: Open Applications, go to Utilities, and select ODBC Manager.
- On Linux: Use the command line to launch ODBC Data Source Administrator or use unixODBC if installed.

Once launched, double-click on the CData Salesforce Data Cloud data Source and enter the required values to establish a connection:
Salesforce Data Cloud supports authentication via the OAuth standard.
OAuth
Set AuthScheme to OAuth.
Desktop Applications
CData provides an embedded OAuth application that simplifies authentication at the desktop.
You can also authenticate from the desktop via a custom OAuth application, which you configure and register at the Salesforce Data Cloud console. For further information, see Creating a Custom OAuth App in the Help documentation.
Before you connect, set these properties:
- InitiateOAuth: GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
- OAuthClientId (custom applications only): The Client ID assigned when you registered your custom OAuth application.
- OAuthClientSecret (custom applications only): The Client Secret assigned when you registered your custom OAuth application.
When you connect, the driver opens Salesforce Data Cloud's OAuth endpoint in your default browser. Log in and grant permissions to the application.
The driver then completes the OAuth process as follows:
- Extracts the access token from the callback URL.
- Obtains a new access token when the old one expires.
- Saves OAuth values in OAuthSettingsLocation so that they persist across connections.
- Launch the Lazarus IDE.
- Navigate to File > New > Application to create a new GUI project with a Main form.
- Go to View > Component > Palette and check the Keep open at the bottom-left to keep the Components window persistently open.
-
Search for the following components and add them to the Main form Form1 by clicking on Use at the bottom right.
- TSQLConnector
- TSQLTransaction
- TSQLQuery
- TDataSource
- TDBGrid
- Select the TSQLConnector component on the Main form.
- Open the Object Inspector if it's not already open by going to View > Object Inspector
- In the Object Inspector on the left, set the following properties under the Properties section:
Property Value Connected True Driver ODBC DatabaseName Your DSN name (e.g., CData Salesforce Data Cloud Source) UserName Your database username Password Your database password HostName Salesforce Data Cloud URL or localhost for local databases LoginPrompt False Transaction Select your TSQLTransaction component - Double-click the Main Form in the Lazarus Pascal IDE to open the code editor.
- Locate the procedure TForm1.FormCreate(Sender: TObject); section.
- Paste the following code below the begin keyword. Replace 'your_security_token' with your actual security token:
SQLConnector1.Params.Values ['Password'] := SQLConnector1.Params.Values ['Password'] + 'your_security_token';
- Select the TSQLQuery component in the Main form.
- Set the following properties in the Object Inspector under the Properties section:
Property Value Active True DataBase Select the name of your TSQLConnector component SQL (Click 3 dots) Your query (e.g., SELECT * FROM Account) Transaction Your TSQLTransaction component - Select the TDataSource component and set its DataSet property to the name of your TSQLQuery component.
- Select the TDBGrid component and set its DataSource property to your TDataSource component.
- Select the TSQLTransaction component. Set the following properties:
- Active: True
- Database: The name of your TSQLConnector component
- Double-click on the Main Form to open up the Source Editor.
- Add the following code under the begin keyword and before the end. keyword.
- Enhance Your TDBGrid: Customize your TDBGrid to enable sorting, editing, or highlighting specific rows.
- Visualize Your Data: Use components like TChart to create graphs and charts for intuitive data representation.
- Filter and Search: Use components like TDBFilter or implement custom filtering logic to allow users to quickly focus on relevant data. Add a TEdit component for user input and link it to your filtering functionality.
- Export Your Data: Utilize TSVExport or TFileStream components to save your data in formats like CSV or Excel for sharing or integration into other systems.
- Perform Calculations: Use TFPCustomDataSet or your dataset's built-in features to calculate totals, averages, or other metrics. Display results in a TLabel or add them to your TDBGrid.
- Create Forms and Reports: Design interactive forms using TForm and TDBEdit for user interaction. For reports, integrate components like RLReport or FastReport to generate and print professional-quality reports.
For other OAuth methods, including Web Applications and Headless Machines, refer to the Help documentation.

Create a New GUI Project

Add Required Connection Components to the Form



Configure the TSQLConnector Component
The TSQLConnector component in Lazarus Pascal IDE facilitates connections between your application and various databases or database APIs. Here's how to configure it:
If your credentials require a security token, follow these steps:



Configure the TSQLQuery Component
The TSQLQuery component in Lazarus Pascal IDE receives SQL code for queries and retrieves data from a database, simplifying data manipulation. Configure using the following info:



Configure the TDataSource, TDBGrid, TSQLTransaction Components
The TDataSource component in Lazarus Pascal IDE bridges a dataset (e.g., TSQLQuery) with data-aware controls like TDBGrid, allowing data to be displayed and manipulated. The TDBGrid presents the data in a tabular format, while the TSQLTransaction ensures database operations maintain data integrity by executing within a transaction. Here's how to configure all three components:



Add Code to Test the Connection
To successfully test the connection, use the following code:
procedure TForm1.FormCreate(Sender: TObject);
begin
// Code for your Security Token
SQLConnector1.Params.Values ['Password'] :=
SQLConnector1.Params.Values ['Password'] + 'your_security_token';
try
SQLConnector1.Open;
ShowMessage('Connection successful!');
except
on E: Exception do
ShowMessage('Error: ' + E.Message);
end;
try
SQLQuery1.Open;
if SQLQuery1.IsEmpty then
ShowMessage('No data found.')
else
ShowMessage('Data loaded successfully.');
except
on E: Exception do
ShowMessage('Error: ' + E.Message);
end;
end;
end.

Compile and Run the Application
Save your project. Go to Run > Compile, then Run, or use the shortcut F9 to execute your application.



Next Steps: Play with the Data
Now that your data is successfully imported into Lazarus, here are some ideas to explore its full potential:
Take your data-driven application to the next level with these enhancements!
Simplify Data Connectivity in Lazarus with CData
Unlock the full potential of live Salesforce Data Cloud data directly within Lazarus Pascal. Streamline your workflows, enhance productivity, and experience seamless integration like never before.
Start your free trial today and transform the way you connect and work with your data!