| Quick Start: FlexPivot for WinForms > Using FlexPivot Controls with Data Source > Binding FlexPivot to Data Source in Code |
You can also bind the FlexPivot controls to a data source kept locally at your machine in code. Follow the given steps to bind the FlexPivotPage control to data source (c1nwind.mdb) in code.
Private Shared Function GetConnectionString() As String Dim path As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\ComponentOne Samples\Common" Dim conn As String = "provider=microsoft.jet.oledb.4.0;data source={0}\c1nwind.mdb;" Return String.Format(conn, path) End Function
static string GetConnectionString() { string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + @"\ComponentOne Samples\Common"; string conn = @"provider=microsoft.jet.oledb.4.0;data source={0}\c1nwind.mdb;"; return string.Format(conn, path); }
This code creates a connection with the c1nwind.mdb database file installed on your system at Documents\ComponentOne Samples\Common location on your system.
' load data Dim da = New OleDbDataAdapter("select * from invoices", GetConnectionString()) Dim dt = New DataTable() da.Fill(dt)
// load data var da = new OleDbDataAdapter("select * from invoices", GetConnectionString()); var dt = new DataTable(); da.Fill(dt);
' bind data Me.C1FlexPivotPage1.DataSource = dt
// bind data this.c1FlexPivotPage1.DataSource = dt;

You can now create different views by dragging the data fields to Rows, Columns and Values list for data analysis.