![]() |
VOOZH | about |
DataBinding facilitates two-way interaction with data through UI controls. Using the CData ADO.NET Provider for Dynamics CRM streamlines the process of binding Dynamics CRM data to Windows Forms and Web controls within Visual Studio. In this article, we will demonstrate using wizards to establish a binding between Dynamics CRM 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.
CData simplifies access and integration of live Microsoft Dynamics CRM data. Our customers leverage CData connectivity to:
CData customers use our Dynamics CRM connectivity solutions for a variety of reasons, whether they're looking to replicate their data into a data warehouse (alongside other data sources) or analyze live Dynamics CRMa data from their preferred data tools inside the Microsoft ecosystem (Power BI, Excel, etc.) or with external tools (Tableau, Looker, etc.).
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 Dynamics CRM, follow the steps outlined below using the Data Source Configuration Wizard. Within the wizard, you'll have the option to choose the specific Dynamics CRM entities you wish to bind to.
In the Add Connection dialog, click Change to select the CData Dynamics CRM Data Source.
Below is a typical connection string:
User=myuseraccount;Password=mypassword;URL=https://myOrg.crm.dynamics.com/;CRM Version=CRM Online;
The connection string options meet the authentication and connection requirements of different Dynamics CRM instances. To connect to your instance, set the User and Password properties, under the Authentication section, to valid Dynamics CRM user credentials and set the Url to a valid Dynamics CRM server organization root. Additionally, set the CRMVersion property to 'CRM2011+' or 'CRMOnline'. IFD configurations are supported as well; set InternetFacingDeployment to true.
Additionally, you can provide the security token service (STS) or AD FS endpoint in the STSURL property. This value can be retrieved with the GetSTSUrl stored procedure. Office 365 users can connect to the default STS URL by simply setting CRMVersion.
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 FirstName and the y-axis to NumberOfEmployees.
The chart is now databound to the Dynamics CRM data. Run the chart to display the current data.
๐ The chart, filled with data at run time.
DataBinding to Dynamics CRM data requires only a few lines of code and can be completed in three easy steps.
Below is the complete code:
DynamicsCRMConnection conn = new DynamicsCRMConnection("User=myuseraccount;Password=mypassword;URL=https://myOrg.crm.dynamics.com/;CRM Version=CRM Online;");
DynamicsCRMCommand comm = new DynamicsCRMCommand("SELECT Contact.FirstName, SUM(Account.NumberOfEmployees) FROM Contact, Account GROUP BY Contact.FirstName", conn);
DynamicsCRMDataAdapter da = new DynamicsCRMDataAdapter(comm);
DataSet dataset = new DataSet();
da.Fill(dataset);
chart1.DataSource = dataset;
chart1.Series[0].XValueMember = "FirstName";
chart1.Series[0].YValueMembers = "NumberOfEmployees";
// Insert code for additional chart formatting here.
chart1.DataBind();
Download a free trial of the Dynamics CRM Data Provider to get started:
Download NowLearn more:
๐ Dynamics CRM IconRapidly create and deploy powerful .NET applications that integrate with Microsoft Dynamics CRM account data including Leads, Contacts, Opportunities, Accounts, and more!