Connect to Sage X3 Cloud Data from PowerBuilder via ODBC

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
This article demonstrates how to use the CData ODBC Driver for Sage X3 Cloud to connect to Sage X3 Cloud data and execute queries in PowerBuilder.

The CData ODBC Driver for Sage X3 Cloud can be used from any platform or development technology that supports ODBC, including PowerBuilder. This article shows how to connect to Sage X3 Cloud data and execute queries from the Database Painter and controls such as the DataWindow.

Connect to Sage X3 Cloud as an ODBC Data Source

If you have not already, first specify connection properties in an ODBC DSN (data source name). This is the last step of the driver installation. You can use the Microsoft ODBC Data Source Administrator to create and configure ODBC DSNs.

Sage X3 Cloud uses the OAuth 2.0 Client Credentials flow, and an X-API-Key is also required for API access. Set AuthScheme to OAuth and specify the following connection properties:

  • URL: The base URL of your Sage X3 Cloud instance.
  • OAuthAccessTokenUrl: The OAuth token endpoint (e.g., https://your-auth-domain/oauth/token).
  • OAuthClientId: Your OAuth application client ID.
  • OAuthClientSecret: Your OAuth application client secret.
  • Audience: The API audience value for the token request.
  • XAPIKey: The X-API-Key provided by your Sage X3 Cloud administrator.
  • Folder: The Sage X3 folder name (e.g., SEED). This folder is used as the default schema.
  • Folders (optional): A comma-separated list of Sage X3 folders (e.g., SEED,PERF). Each folder is exposed as a separate schema, so you can query across folders with the Schema.Table syntax.

The driver obtains an access token with the Client Credentials flow and sends it with the X-API-Key on every API request. With InitiateOAuth set to GETANDREFRESH (the default), the driver acquires and refreshes the token automatically.

Create a Profile for the ODBC Driver for Sage X3 Cloud

Follow the steps below to use the Database Painter tool to create a database profile based on an ODBC DSN (data source name) for Sage X3 Cloud. In the Database Painter, you can use wizards and the UI to work with Sage X3 Cloud data.

  1. In PowerBuilder, click Tools -> Database Painter.
  2. In the Objects window in the Database Painter, right-click the ODBC node and click New Profile.
  3. On the Connection tab, enter a name for the profile and select the Sage X3 Cloud DSN in the Data Source menu. The ODBC DSN, required to create the Database Profile. (Salesforce is shown.)
  4. To view and modify a table, right-click a table and then click Edit Data -> Grid.
Live data accessible from an editable grid. (Salesforce is shown.)

Using Sage X3 Cloud Data with PowerBuilder Controls

You can use standard PowerBuilder objects to connect to ODBC data sources and execute queries. The following example shows how to retrieve Sage X3 Cloud data into a DataWindow. You can add the following code to the open method:


SQLCA.DBMS = "ODBC"
SQLCA.DBParm = "ConnectString='DSN=CData SageX3Cloud Source'"
CONNECT USING SQLCA;
dw_bpcustomer.SetTransObject(SQLCA);
dw_bpcustomer.Retrieve();

Ready to get started?

Download a free trial of the Sage X3 Cloud ODBC Driver to get started:

 Download Now

Learn more:

Sage X3 Cloud Icon Sage X3 Cloud ODBC Driver

The Sage X3 Cloud ODBC Driver is a powerful tool that allows you to connect with live data from Sage X3 Cloud, directly from any applications that support ODBC connectivity.

Access Sage X3 Cloud data like you would a database - read, write, and update Sage X3 Cloud data through a standard ODBC Driver interface.