FlexReport for UWP | ComponentOne
Working with FlexReport / Data Binding in FlexReport / Data Binding using SQLite
In This Topic
    Data Binding using SQLite
    In This Topic

    FlexReport supports data binding using SQLite. SQLite is a software library and widely used SQL database engine. It does not have a separate server process so it can read and write directly to different files in ordinary disks.

    For binding data using SQLite, you are required to use FlexReport.SQLite project, which is available in Documents\ComponentOne Samples\UWP\C1.UWP.FlexReport\CS folder. You need to add FlexReport.SQLite project to the solution of your app's project, as it is required for FlexReport to be able to use SQLite.

    The following code illustrates the use of SQLite for data binding:

    1. Add the following code to create a database connection:
      ' Copy the SQLite database file from app's Assets to LocalFolder - in a .FLXR report definition
      Dim dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "C1NWind.db")
      If Not File.Exists(dbPath) Then
              File.Copy("Assets\C1NWind.db", dbPath)
      End If
      
      // Copy the SQLite database file from app's Assets to LocalFolder - in a .FLXR report definition
      var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "C1NWind.db");
      if (!File.Exists(dbPath))
        File.Copy(@ "Assets\C1NWind.db", dbPath);
      
    2. Add the following code to create and load a report:
      ' Create and load the report:
      Dim report As New C1FlexReport()
      Using fs As Stream = File.OpenRead("Assets/ProductsUWP.flxr")
              report.Load(fs, "ProductList")
      End Using
      
      // Create and load the report:
      C1FlexReport report = new C1FlexReport();
      using(Stream fs = File.OpenRead("Assets/ProductsUWP.flxr"))
      report.Load(fs, "ProductList");
      
    3. Render the report in FlexViewer control using the following code:
      Me.flexViewer.DocumentSource = report
      
      this.flexViewer.DocumentSource = report;