FlexChart | ComponentOne
In This Topic
    Step 1: Creating a Data Source for FlexChart
    In This Topic

    Adding a New Data Source

    1. From the Visual Studio PROJECT menu, select Add New Data Source.
      Data Source Configuration Wizard appears.
    2. Select Database, then click Next.
    3. Select Dataset, then click Next.
    4. Click New Connection.
    5. Select Data source as Microsoft Access Database File (OLE DB).
    6. Click Browse for adding Database file name as C1NWind.mdb.
    7. Navigate to the default location of C1NWind.mdb database (located by default in C:\Users\Documents\ComponentOne Samples\Common), then click Open, and then click OK.
    8. Click Next.
      A dialog box appears to check if you would like to add the data file to your project and modify the connection string. Since it is not necessary to copy the database to your project, click No.
    9. Verify that the Yes, save the connection as check box is checked and click Next to continue.
      The connection string is saved as C1NWindConnectionString
    10. Expand the Tables node, and then select the Categories and the Products object.
    11. Click Finish.
      C1NWindDataSet.xsd is added to the project.

    Adding a OleDbDataAdapter

    1. From the Visual Studio Toolbox, double-click the OleDbDataAdapter component.
      In Visual Studio, right-click anywhere inside the Toolbox, and then select Choose Items. On the .NET Framework Components tab in the dialog box, select OleDbDataAdapter
      .
      oleDbDataAdapter1 is added to the component tray and Data Adapter Configuration Wizard appears.
    2. Select the connection you wish to use for the data adapter from the drop-down listbox (in this case, C:\Users\Documents\ComponentOne Samples\Common\C1NWind.mdb), and then click Next.
      Use SQL statements is clicked by default.
    3. Click Next.
    4. Copy and paste the following SQL statement in the textbox of Data Adapter Configuration Wizard:
      SELECT CategoryID, ProductName, UnitPrice, UnitsInStock, ReorderLevel FROM Products ORDER BY UnitPrice DESC
    5. Click Next, then click Yes to add primary key columns to your query.
    6. Click Finish.
      oleDbConnection1 is added to the component tray.

    Generating a DataSet

    1. Select oleDbDataAdapter1, then click on its smart tag, and then click Generate DataSet.
      Generate Dataset appears.
    2. Verify that the Existing radio button is clicked, the Products table is selected, and Add this dataset to the designer is selected, and then click OK.
      c1NWindDataSet1 is added to the component tray.

    Adding Another OleDbDataAdapter

    1. From the Visual Studio Toolbox, double-click the OleDbDataAdapter component and Data Adapter Configuration Wizard appears.
      oleDbDataAdapter2 is added to the component tray.
    2. Select the data connection that shows the directory, ACCESS. C:\Users\Documents\ComponentOne Samples\Common\C1NWind.mdb from the drop-down listbox.
    3. Click Next.
    4. Verify that Use SQL statements is clicked, and then click Next.
    5. Copy and paste the following SQL statement in the textbox of Data Adapter Configuration Wizard:
      SELECT CategoryName, CategoryID FROM Categories
    6. Click Next, and then click Finish.

    Generating a DataSet for the Second OleDbDataAdapter

    1. Select oleDbDataAdapter2, then click on its smart tag, and then click Generate DataSet.
    2. In Generate Dataset, click New, and then name it as categoriesDataSet.
    3. Verify that the Categories table is selected, Add this dataset to the designer is selected, and then click OK.
      categoriesDataSet1 is added to the component tray.

    Filling the DataSets

    To fill the datasets, add the following code in the Form1_Load event:

    Title Text
    Copy Code
    Type your code here.

    Adding the DataView Component

    1. From the Visual Studio Toolbox, double-click the DataView component.
      In Visual Studio, right-click anywhere inside the Toolbox, and then select Choose Items. On the .NET Framework Components tab in the dialog box, select DataView.
      dataView1 is added to the component tray.
    2. Select dataView1.
    3. In the DataView Properties window, set the following properties as given below:
      AllowDelete = False
      AllowEdit = False
      AllowNew = False
      Table = c1nwindDataSet1.Products

      A new data source is created successfully.