Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Objective Grid for Microsoft .NET User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

9.4 DBBrowserGrid - Step 2

This section describes the steps required to complete Step 2 of the DBBrowserGrid tutorial. Step 2 changes the application in Step 1 by adding the database access and by binding the DBBrowserGrid control to different data access objects from ADO.NET.

If you want to retain the work done in Step 1, create a separate copy of it.

9.4.1 Add Another Form to the Project

  1. In the Solution Explorer, right-click the project. In the popup menu, select Add | Add Windows Form… .

  2. Select FrmAdoObjs. If the properties for FrmAdoObjs are not already displayed, right-click the form; a context menu is displayed. Select Properties from the context menu.

  3. In the resulting property grid for the form, change the following properties.

9.4.2 Add a Menu

  1. Drag a MainMenu component onto FrmAdoObjs.

  2. Add an item to the main menu with the title "&ADO.NET".

  3. Add items to the ADO.NET submenu with the following titles:

  4. Return to the FrmMain designer and add an "ADO.NET objects" item to the Bind to… item of the main menu. Double-click ADO.NET objects. The code for

    appears. Enter the following code as the function body:

    This creates the instance of FrmAdoObjs and adds it as a MDI child to the main application window.

9.4.3 Add a DBBrowserGrid Control

  1. Select and drag a DBBrowserGrid from the Toolbox onto the form.

  2. Select the DBBrowserGrid control. In the property grid for the control, change the following Grid Control properties:

  3. Add the data access capabilities to the application: Copy the Northwind.mdb MS Access database file from the CD to the solution directory. Make sure that Microsoft JET 4.0 OLE DB provider is present on your computer.

  4. Drag an OleDbDataAdapterComponent from toolbox to FrmAdoObjs. The Data Adapter Configuration Wizard appears. Configure the adapter for using the Microsoft JET 4.0 OLE DB provider and the Northwind.mdb database:

  5. Drag a DataView component to FrmAdoObjs.

  6. Double-click the FrmAdoObjs form. The code for

    appears. Enter the following code as the function body:

    The code will be executed on the Form. Load event and do the following: open the database connection, populate the dataset with two tables—"customers" and "employees"—and configure the data view for "customers" table.

  7. Return to the FrmAdoObjs designer and double-click ADO.NET | DataSet, ADO.NET | DataTable, and ADO.NET | DataView on the main menu. The code for

    appears. Enter the following code as the function body:

  8. Build and run the application. Create the MDI child window, click several times on the different items in the ADO.NET menu. You can see how different elements are bound and data from them are displayed in the DBBrowserGrid control. You can edit the records and see that changes are actually stored in the recordset. Changes are not submitted to the database because that task is beyond the scope of the data representation components.

    Figure 54: Completed DBBrowserGrid Step 2 in Action



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.