Now that a Microsoft Entity Data Model has been created for the PostgreSQL database, Entity Framework applications can be created to make use of it.

This section details the steps required to create a simple Visual Studio 2008 Windows Form application, with associated DataGridView control for displaying data in selected tables from the target database.

  1. Launch the Visual Studio 2008 SP1 IDE.

    Figure 8.473. Visual Studio 2008 SP1 IDE

    Visual Studio 2008 SP1 IDE

  2. Create a

    Web Application

    project by going to the

    File

    menu in Visual Studio and choosing

    New Project

    .

    Figure 8.474. Web Application

    Web Application

  3. When the New Project window appears, choose either

    Visual Basic

    or

    Visual C#

    as your programming language.

  4. Within the language category, click on

    Windows

    and select

    Windows Form Application

    from the right-hand panel.

  5. Choose a name for the project, for example

    VirtWindowsFormApplication

    , and click

    OK

    .

    Figure 8.475. Web Application

    Web Application

  6. In the

    Toolbox

    , expand

    Data Controls

    , and drag the

    DataGridView

    control onto the form.

    Figure 8.476. Toolbox

    Toolbox

  7. Click on the little

    arrow

    in the top right of the

    DataGridView

    control. This loads the

    DataGridView Task

    menu.

    Figure 8.477. DataGridView Task

    DataGridView Task

  8. Click on the

    Choose Data Source

    list box.

    Figure 8.478. Choose Data Source

    Choose Data Source

  9. Click on the

    Add Project Data Source

    link to connect to a data source.

    Figure 8.479. Add Project Data Source

    Add Project Data Source

  10. In the

    Data Source Configuration Wizard

    dialog

    Choose Data Source Type

    page select the

    Database

    data source type and click

    Next

    .

    Figure 8.480. Data Source Type

    Data Source Type

  11. In the

    Data Source Configuration Wizard

    dialog

    Choose your Data Connection

    page, select the

    New Connection

    button

    Figure 8.481. Data Source Configuration Wizard

    Data Source Configuration Wizard

  12. In the

    Choose Data Source

    dialog, select the OpenLink

    Virtuoso Data Source

    from the list and click

    Continue

    .

    Figure 8.482. Data Source

    Data Source

  13. In the

    Add Connection

    dialog, specify the

    hostname, portno, username and password

    for the target Virtuoso Server and check the Save Password check box.

    Figure 8.483. Connection Properties

    Connection Properties

  14. Select the

    Select Database From List

    radio button and choose the

    Northwind

    database from the drop down list.

    Figure 8.484. Add connection

    Add connection

  15. Press the

    Test Connection

    dialog to verify that the database is accessible.

    Figure 8.485. Test Connection

    Test Connection

  16. Leave the default connect string

    NorthwindConnectionString

    and click

    Next

    Figure 8.486. NorthwindConnectionString

    NorthwindConnectionString

  17. From the list of available tables returned for the Northwind database, select the

    Shippers

    table to be associated with the

    DataGridView

    control.

    Figure 8.487. Northwind database

    Northwind database

  18. The columns names of the select table will be displayed in the DataGridView.

    Figure 8.488. DataGridView

    DataGridView

  19. Resize the Form and DataGridView to allow all columns to be visible, if possible.

    Figure 8.489. Resize the Form and DataGridView

    Resize the Form and DataGridView

  20. To test the application, simply hit

    Ctrl+F5

    within Visual Studio or select

    Start Debugging

    from the

    Debug

    menu.

    Figure 8.490. Start Debugging

    Start Debugging

  21. The data from the

    Shippers

    table will be displayed in the

    DataGrid

    .

    Figure 8.491. DataGrid

    DataGrid

The task is now complete.