![]() |
VOOZH | about |
DataBinding facilitates two-way interaction with data through UI controls. Using the CData ADO.NET Provider for SharePoint streamlines the process of binding SharePoint data to Windows Forms and Web controls within Visual Studio. In this article, we will demonstrate using wizards to establish a binding between SharePoint 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.
Accessing and integrating live data from SharePoint has never been easier with CData. Customers rely on CData connectivity to:
Most customers rely on CData solutions to integrate SharePoint data into their database or data warehouse, while others integrate their SharePoint data with preferred data tools, like Power BI, Tableau, or Excel.
For more information on how customers are solving problems with CData's SharePoint solutions, refer to our blog: Drivers in Focus: Collaboration Tools.
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 SharePoint, follow the steps outlined below using the Data Source Configuration Wizard. Within the wizard, you'll have the option to choose the specific SharePoint entities you wish to bind to.
In the Add Connection dialog, click Change to select the CData SharePoint Data Source.
Below is a typical connection string:
User=myuseraccount;Password=mypassword;Auth Scheme=NTLM;URL=http://sharepointserver/mysite;SharePointEdition=SharePointOnPremise;
Set the URL property to the base SharePoint site or to a sub-site. This allows you to query any lists and other SharePoint entities defined for the site or sub-site.
The User and Password properties, under the Authentication section, must be set to valid SharePoint user credentials when using SharePoint On-Premise.
If you are connecting to SharePoint Online, set the SharePointEdition to SHAREPOINTONLINE along with the User and Password connection string properties. For more details on connecting to SharePoint Online, see the "Getting Started" chapter of 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 Name and the y-axis to Revenue.
The chart is now databound to the SharePoint data. Run the chart to display the current data.
๐ The chart, filled with data at run time.
DataBinding to SharePoint data requires only a few lines of code and can be completed in three easy steps.
Below is the complete code:
SharePointConnection conn = new SharePointConnection("User=myuseraccount;Password=mypassword;Auth Scheme=NTLM;URL=http://sharepointserver/mysite;SharePointEdition=SharePointOnPremise;");
SharePointCommand comm = new SharePointCommand("SELECT Name, Revenue FROM MyCustomList", conn);
SharePointDataAdapter da = new SharePointDataAdapter(comm);
DataSet dataset = new DataSet();
da.Fill(dataset);
chart1.DataSource = dataset;
chart1.Series[0].XValueMember = "Name";
chart1.Series[0].YValueMembers = "Revenue";
// Insert code for additional chart formatting here.
chart1.DataBind();
Download a free trial of the SharePoint Data Provider to get started:
Download NowLearn more:
๐ SharePoint IconProvides .NET developers with the power to easily connect their Web, Desktop, and Mobile applications to data in SharePoint Server Lists, Contacts, Calendar, Links, Tasks, and more!