Connect to Sage X3 Cloud Data from PowerBuilder via ADO.NET

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
This article demonstrates how to access Sage X3 Cloud data from Appeon PowerBuilder using the CData ADO.NET Provider for Sage X3 Cloud.

This article demonstrates using the CData ADO.NET Provider for Sage X3 Cloud in PowerBuilder, showcasing the ease of use and compatibility of these standards-based controls across various platforms and development technologies that support Microsoft .NET, including Appeon PowerBuilder.

This article shows how to create a basic PowerBuilder application that uses the CData ADO.NET Provider for Sage X3 Cloud to retrieve data.

  1. In a new WPF Window Application solution, add all the Visual Controls needed for the connection properties. Below is a typical connection string:

    AuthScheme=OAuth;URL=https://x3server/;OAuthAccessTokenUrl=https://auth-domain/oauth/token;OAuthClientId=your_client_id;OAuthClientSecret=your_client_secret;Audience=https://api-audience;XAPIKey=your_api_key;Folder=SEED;

    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.

  2. Add the DataGrid control from the .NET controls.
  3. Configure the columns of the DataGrid control. Below are several columns from the Account table:
    
    
    <DataGrid AutoGenerateColumns="False" Margin="13,249,12,14" Name="datagrid1" TabIndex="70" ItemsSource="{Binding}">
    <DataGrid.Columns>
        <DataGridTextColumn x:Name="idColumn" Binding="{Binding Path=Id}" Header="Id" Width="SizeToHeader" />
        <DataGridTextColumn x:Name="nameColumn" Binding="{Binding Path=BPCNUM}" Header="BPCNUM" Width="SizeToHeader" />
    		...
    	</DataGrid.Columns>
    </DataGrid>
    
  4. Add a reference to the CData ADO.NET Provider for Sage X3 Cloud assembly.

Connect the DataGrid

Once the visual elements have been configured, you can use standard ADO.NET objects like Connection, Command, and DataAdapter to populate a DataTable with the results of an SQL query:


System.Data.CData.SageX3Cloud.SageX3CloudConnection conn 
conn = create System.Data.CData.SageX3Cloud.SageX3CloudConnection(connectionString)

System.Data.CData.SageX3Cloud.SageX3CloudCommand comm 
comm = create System.Data.CData.SageX3Cloud.SageX3CloudCommand(command, conn)

System.Data.DataTable table
table = create System.Data.DataTable

System.Data.CData.SageX3Cloud.SageX3CloudDataAdapter dataAdapter
dataAdapter = create System.Data.CData.SageX3Cloud.SageX3CloudDataAdapter(comm)
dataAdapter.Fill(table)	
datagrid1.ItemsSource=table.DefaultView

The code above can be used to bind data from the specified query to the DataGrid.

Ready to get started?

Download a free trial of the Sage X3 Cloud Data Provider to get started:

 Download Now

Learn more:

Sage X3 Cloud Icon Sage X3 Cloud ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Sage X3 Cloud.