![]() |
VOOZH | about |
DataBinding facilitates two-way interaction with data through UI controls. Using the CData ADO.NET Provider for Power BI XMLA streamlines the process of binding Power BI XMLA data to Windows Forms and Web controls within Visual Studio. In this article, we will demonstrate using wizards to establish a binding between Power BI XMLA data and a chart that dynamically updates. Additionally, the code walk-through section will guide you through the creation of a chart using just 10 lines of code.
DataBinding to a Chart consists of three steps: Instantiate the control, configure the data source, and databind.
To create a chart control and establish a connection to Power BI XMLA, follow the steps outlined below using the Data Source Configuration Wizard. Within the wizard, you'll have the option to choose the specific Power BI XMLA entities you wish to bind to.
In the Add Connection dialog, click Change to select the CData Power BI XMLA Data Source.
Below is a typical connection string:
AuthScheme=EntraID;InitiateOAuth=GETANDREFRESH;
By default, use Entra ID (formerly Azure AD) to connect to Microsoft Power BI XMLA. Entra ID (formerly Azure AD) is Microsoft's multi-tenant, cloud-based directory and identity management service. It is user-based authentication that requires that you set AuthScheme to EntraID (formerly AzureAD).
For more information on other authentication schemes, refer to the Help documentation.
When you configure the connection, you may also want to set the Max Rows connection property. This will limit the number of rows returned, which is especially helpful for improving performance when designing reports and visualizations.
๐ Connection properties for the selected data source in the Add Connection dialog. (Salesforce is shown.)After adding the data source and selecting database objects, you can bind the objects to the chart. This example assigns the x-axis to Country and the y-axis to Education.
The chart is now databound to the Power BI XMLA data. Run the chart to display the current data.
๐ The chart, filled with data at run time.
DataBinding to Power BI XMLA data requires only a few lines of code and can be completed in three easy steps.
Below is the complete code:
PowerBIXMLAConnection conn = new PowerBIXMLAConnection("AuthScheme=EntraID;InitiateOAuth=GETANDREFRESH;");
PowerBIXMLACommand comm = new PowerBIXMLACommand("SELECT Country, Education FROM Customer WHERE Country = 'Australia'", conn);
PowerBIXMLADataAdapter da = new PowerBIXMLADataAdapter(comm);
DataSet dataset = new DataSet();
da.Fill(dataset);
chart1.DataSource = dataset;
chart1.Series[0].XValueMember = "Country";
chart1.Series[0].YValueMembers = "Education";
// Insert code for additional chart formatting here.
chart1.DataBind();
Download a free trial of the Power BI XMLA Data Provider to get started:
Download NowLearn more:
๐ Power BI XMLA IconRapidly create and deploy powerful .NET applications that integrate with Power BI XMLA.