Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 71d40963b505df4524269198e237b3e3 > files > 784

virtuoso-opensource-doc-6.1.4-2.fc14.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
 <head profile="http://internetalchemy.org/2003/02/profile">
  <link rel="foaf" type="application/rdf+xml" title="FOAF" href="http://www.openlinksw.com/dataspace/uda/about.rdf" />
  <link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" />
  <meta name="dc.title" content="2. Installation Guide" />
  <meta name="dc.subject" content="2. Installation Guide" />
  <meta name="dc.creator" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="dc.copyright" content="OpenLink Software, 1999 - 2009" />
  <link rel="top" href="index.html" title="OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="search" href="/doc/adv_search.vspx" title="Search OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="parent" href="installation.html" title="Chapter Contents" />
  <link rel="prev" href="installvsgrid.html" title="Virtuoso ADO.Net Data Grid Form Application" />
  <link rel="next" href="installusado.html" title="Using Visual Studio 2008 to Build an ADO.NET Data Services based Application" />
  <link rel="shortcut icon" href="../images/misc/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" type="text/css" href="doc.css" />
  <link rel="stylesheet" type="text/css" href="/doc/translation.css" />
  <title>2. Installation Guide</title>
  <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
  <meta name="author" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="copyright" content="OpenLink Software, 1999 - 2009" />
  <meta name="keywords" content="" />
  <meta name="GENERATOR" content="OpenLink XSLT Team" />
 </head>
 <body>
  <div id="header">
    <a name="installvsent" />
    <img src="../images/misc/logo.jpg" alt="" />
    <h1>2. Installation Guide</h1>
  </div>
  <div id="navbartop">
   <div>
      <a class="link" href="installation.html">Chapter Contents</a> | <a class="link" href="installvsgrid.html" title="Virtuoso ADO.Net Data Grid Form Application">Prev</a> | <a class="link" href="installusado.html" title="Using Visual Studio 2008 to Build an ADO.NET Data Services based Application">Next</a>
   </div>
  </div>
  <div id="currenttoc">
   <form method="post" action="/doc/adv_search.vspx">
    <div class="search">Keyword Search: <br />
        <input type="text" name="q" /> <input type="submit" name="go" value="Go" />
    </div>
   </form>
   <div>
      <a href="http://www.openlinksw.com/">www.openlinksw.com</a>
   </div>
   <div>
      <a href="http://docs.openlinksw.com/">docs.openlinksw.com</a>
   </div>
    <br />
   <div>
      <a href="index.html">Book Home</a>
   </div>
    <br />
   <div>
      <a href="contents.html">Contents</a>
   </div>
   <div>
      <a href="preface.html">Preface</a>
   </div>
    <br />
   <div class="selected">
      <a href="installation.html">Installation Guide</a>
   </div>
    <br />
   <div>
      <a href="installwin32.html">Virtuoso for Windows</a>
   </div>
   <div>
      <a href="linuxinstall.html">Virtuoso for Linux (Enterprise Edition)</a>
   </div>
   <div>
      <a href="unxinstvirt.html">Virtuoso for Unix (Enterprise Edition)</a>
   </div>
   <div>
      <a href="unixpersonainstall.html">Virtuoso for Unix (Personal Edition)</a>
   </div>
   <div>
      <a href="installmacosx.html">Virtuoso for Mac OS X</a>
   </div>
   <div>
      <a href="installvsgrid.html">Virtuoso ADO.Net Data Grid Form Application</a>
   </div>
   <div class="selected">
      <a href="installvsent.html">Using Visual Studio 2008 to Build an Entity Frameworks based Windows Form Application</a>
    <div>
        <a href="#installvsentprereq" title="Pre-requisites">Pre-requisites</a>
        <a href="#installvsentcreatedb" title="Create the School database and schema">Create the School database and schema</a>
        <a href="#installvsentgenmodel" title="Generating the School Entity Data Mode">Generating the School Entity Data Mode</a>
        <a href="#installvsentqueryentity" title="Querying Entities and Associations">Querying Entities and Associations</a>
        <a href="#installvsentinsertandupdate" title="Inserting and Updating Data">Inserting and Updating Data</a>
    </div>
   </div>
   <div>
      <a href="installusado.html">Using Visual Studio 2008 to Build an ADO.NET Data Services based Application</a>
   </div>
   <div>
      <a href="installwfas.html">Windows Form Application for accessing Virtuoso RDF data via SPASQL using the Virtuoso ADO.Net Provider</a>
   </div>
   <div>
      <a href="installcrweb.html">Creating a Web Browser Application to Access RDF Data Using The Virtuoso ADO.Net Provider</a>
   </div>
   <div>
      <a href="installsilver.html">Creating a Silverlight Application to consume the service</a>
   </div>
   <div>
      <a href="installnetriadd.html">Creating A Simple .NET RIA Services Application To Display Data
From Virtuoso</a>
   </div>
   <div>
      <a href="installnetriavd.html">Creating a .Net RIA Services Application That Will Update Virtuoso Data</a>
   </div>
   <div>
      <a href="clusterstcnf.html">Cluster Installation and Config</a>
   </div>
    <br />
  </div>
  <div id="text">
    <a name="installvsent" />
    <h2>2.7. Using Visual Studio 2008 to Build an Entity Frameworks based Windows Form Application</h2>
    <div class="formalpara">
      <strong>Virtuoso Entity Framework School DB Windows Form Application</strong>
    </div>
    <p>This section demonstrates how Visual Studio 2008 can be used to generate mapping files
for an Entity Data Model (EDM), based on a 1:1 mapping to tables in the School database. This will be
done by creating a Windows Forms application in Visual Studio, create queries that access data in the
School model, bind the query results to display controls to show the results of the queries, and then
make updates to objects and persist the changes to the database.</p>
      
        <a name="installvsentprereq" />
    <h3>2.7.1. Pre-requisites</h3>
        <p>In order to create an Entity Framework Application in your own environment you will need:</p>
        <ol>
      <li>Microsoft Visual Studio 2008 SP1, the ADO.NET Entity Framework runtime and associated tools are included in Visual Studio 2008 SP1.</li>
      <li>A running Virtuoso Universal Server instance.</li>
    </ol>
      <br />
      
        <a name="installvsentcreatedb" />
    <h3>2.7.2. Create the School database and schema</h3>
        <ol>
      <li>Download the <a href="http://download.openlinksw.com/packages/5.0/virtuoso/schools_db_dav.vad">Schools Database</a> VAD (schools_db_dav.vad) package.</li>
      <li>Navigate to the <strong>System Admin -&gt; Packages</strong> tab of the Virtuoso Conductor.
            <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Conductor Packages" src="../images/ui/uado1.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.2.1. Conductor Packages</td>
      </tr>
        </table>
          </li>
      <li>Scroll down to the <strong>Install Package</strong> section of the tab, use the
<strong>Upload Package</strong> option <strong>Browse</strong> button to locate the
schools_db_dav.vad package and click <strong>proceed</strong>.
             <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Install package" src="../images/ui/uado2.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.2.1. Install package</td>
      </tr>
        </table>
           </li>
      <li>Click the <strong>Proceed</strong> button to begin the installation process.
             <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Install package." src="../images/ui/uado3.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.2.1. Install package.</td>
      </tr>
        </table>
           </li>
      <li>Once complete return to the <strong>Packages</strong> tab and scroll down to confirm the *schools_db* package is listed as installed.
             <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Install package" src="../images/ui/uado4.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.2.1. Install package</td>
      </tr>
        </table>
           </li>
    </ol>
        <p>
      <strong>Create the Course Manager application using Visual Studio</strong>
    </p>
        <ol>
      <li>Launch the Visual Studio 2008 SP1 IDE.
            <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Visual Studio 2008 SP1 IDE" src="../images/ui/uados1.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.2.1. Visual Studio 2008 SP1 IDE</td>
      </tr>
        </table>
          </li>
      <li>On the <strong>File menu</strong> click <strong>New Project</strong>.
          </li>
      <li>Choose either <strong>Visual Basic</strong> or <strong>Visual C#</strong> in the
<strong>Project Types</strong> pane.
          </li>
      <li>Select <strong>Windows Forms Application</strong> in the
<strong>Templates</strong> pane.
          </li>
      <li>Enter <strong>CourseManager</strong> for the project name, and then
click <strong>OK</strong>.
            <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Create project" src="../images/ui/uado5.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.2.1. Create project</td>
      </tr>
        </table>
          </li>
    </ol>
        <p>
      <strong>Create the Course Viewer form</strong>
    </p>
        <ol>
      <li>In the <strong>CourseManager</strong> project, select the default form (Form1).
          </li>
      <li>In the <strong>File Properties</strong> pane, change the File Name to
<strong>CourseViewer.vb</strong> or <strong>CourseViewer.cs</strong>.
          </li>
      <li>In <strong>Solution Explorer</strong>, double-click
<strong>CourseViewer.vb</strong> or <strong>CourseViewer.cs</strong> to open the form.
            <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="CourseViewer.vb" src="../images/ui/uado6.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.2.1. CourseViewer.vb</td>
      </tr>
        </table>
          </li>
      <li>In the <strong>Toolbox</strong>, expand <strong>Common Controls</strong>,
drag the <strong>ComboBox</strong> control to the form, and change the name of the control to
<strong>departmentList</strong>.
          </li>
      <li>In the <strong>Toolbox</strong>, drag the <strong>Button</strong>
control to the form, change the <strong>Name</strong> of the control to <strong>closeForm</strong>,
and change the <strong>Text value</strong> to <strong>Close</strong>.
          </li>
      <li>In the <strong>Toolbox</strong>, expand <strong>Data</strong>, drag the
<strong>DataGridView</strong> control to the form, and change the <strong>Name</strong> of
the control to <strong>courseGridView</strong>.
            <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="DataGridView" src="../images/ui/uado7.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.2.1. DataGridView</td>
      </tr>
        </table>
          </li>
      <li>In the <strong>closeForm_Click</strong> event handler method, type the following code that closes the form:
<div>
          <pre class="programlisting">
Visual Basic

&#39; Close the form.
Me.Close()

C#

// Close the form.
this.Close();
</pre>
        </div>
            </li>
    </ol>
        <br />
        
          <a name="installvsentgenmodel" />
    <h3>2.7.3. Generating the School Entity Data Mode</h3>
          <p>
      <strong>Add the ADO.NET Entity Data Model item template</strong>
    </p>
          <ol>
      <li>Select the CourseManager project in Solution Explorer, right-click, point to Add, and then click New Item.</li>
      <li>Select ADO.NET Entity Data Model in the Templates pane.</li>
      <li>Type School.edmx for the model name and click Add. The opening page of the Entity Data Model Wizard is displayed.
              <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="School.edmx" src="../images/ui/uado8.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.3.1. School.edmx</td>
      </tr>
        </table>
            </li>
    </ol>
          <p>
      <strong>Generate the EDM</strong>
    </p>
          <ol>
      <li>Select <strong>Generate from database</strong> in the
<strong>Choose Model Contents dialog box</strong>. Then click <strong>Next</strong>.
              <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Model Contents" src="../images/ui/uado9.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.3.1. Model Contents</td>
      </tr>
        </table>
            </li>
      <li>Click the <strong>New Connection</strong> button.
              <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="New Connection" src="../images/ui/uado10.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.3.1. New Connection</td>
      </tr>
        </table>
            </li>
      <li>Choose the OpenLink <strong>Virtuoso Data Source</strong> and click
<strong>Continue</strong>.
              <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Virtuoso Data Source" src="../images/ui/uado11.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.3.1. Virtuoso Data Source</td>
      </tr>
        </table>
            </li>
      <li>In the <strong>Connection Properties</strong> dialog specify the
<strong>hostname, portno, username and password</strong> for the target Virtuoso Server and click the
<strong>Advanced</strong> button.
             <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Connection Properties" src="../images/ui/uado12.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.3.1. Connection Properties</td>
      </tr>
        </table>
           </li>
      <li>In the <strong>Advanced Properties</strong> dialog set the
<strong>Database parameter</strong> to <strong>School</strong> and click OK.
             <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Advanced Properties" src="../images/ui/uado13.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.3.1. Advanced Properties</td>
      </tr>
        </table>
           </li>
      <li>Press the <strong>Test Connection</strong> dialog to verify the database is accessible.
             <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Test Connection" src="../images/ui/uado14.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.3.1. Test Connection</td>
      </tr>
        </table>
           </li>
      <li>Set the <strong>entity connect string name</strong> to
<strong>SchoolEntities</strong> and click <strong>Next</strong>.
             <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="entity connect string name" src="../images/ui/uado15.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.3.1. entity connect string name</td>
      </tr>
        </table>
           </li>
      <li>In the <strong>Choose your Database Objects</strong> page select the
<strong>Tables</strong> check box to select all table in the <strong>School database</strong>
for addition to the EDM, set the <strong>Model Namespace</strong> to <strong>SchoolModel</strong>
and click <strong>Finish</strong>.
            <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Database Objects" src="../images/ui/uado16.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.3.1. Database Objects</td>
      </tr>
        </table>
          </li>
    </ol>
        <p>
      <strong>View the EDM in the ADO.NET Entity Data Model Designer</strong>
    </p>
        <ol>
      <li>In the <strong>Solution Explorer</strong>, double-click the
<strong>School.edmx</strong> file. This displays the School model in the ADO.NET Entity Data Model Designer window.
            <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Solution Explorer" src="../images/ui/uado17.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.3.1. Solution Explorer</td>
      </tr>
        </table>
          </li>
      <li>From the <strong>View</strong> menu, select <strong>Other Windows</strong>,
and then click <strong>Model Browser</strong> to display the <strong>Entity Model Browser</strong> window.
          </li>
      <li>Expand the <strong>SchoolModel</strong> and <strong>SchoolModel.Store</strong> nodes to view conceptual and store definitions, respectively.
            <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="SchoolModel" src="../images/ui/uado20.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.3.1. SchoolModel</td>
      </tr>
        </table>
          </li>
      <li>From the <strong>View menu</strong>, select <strong>Other Windows</strong>,
click <strong>Mapping Details</strong>, and then click an entity (Person for example) or association in the Entity Designer.
            </li>
      <li>This displays the Entity Mapping Details window with information about the object-relational mapping for the selected object.
              <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="View menu" src="../images/ui/uado21.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.3.1. View menu</td>
      </tr>
        </table>
            </li>
    </ol>
        <br />
        
          <a name="installvsentqueryentity" />
    <h3>2.7.4. Querying Entities and Associations</h3>
          <p>This section creates strongly-typed queries against the CLR objects that represent entities and associations in the School model, and bind display controls to the object collections returned from these queries.</p>
          <p>
      <strong>Query the departments in the School database</strong>
    </p>
          <ol>
      <li>At the beginning of the code file for the <strong>CourseViewer</strong> form,
add the following <strong>using</strong> (C#) or <strong>Imports</strong> (Visual Basic) statements to reference the model created from the School database and the entity namespace.
<div>
          <pre class="programlisting">
Visual Basic

Imports System.Data.Objects
Imports System.Data.Objects.DataClasses

C#

using System.Data.Objects;
using System.Data.Objects.DataClasses;
</pre>
        </div>
            </li>
      <li>At the top of the partial class definition for the <strong>CourseViewer</strong>
form, add the following code that creates an <strong>ObjectContext</strong> instance.
<div>
          <pre class="programlisting">
Visual Basic

&#39; Create an ObjectContext instance based on SchoolEntity.
Private schoolContext As SchoolEntities

C#

// Create an ObjectContext instance based on SchoolEntity.
private SchoolEntities schoolContext;
</pre>
        </div>
            </li>
      <li>In the <strong>CourseViewer</strong> form designer, double-click
the <strong>CourseViewer</strong> form. This opens the code page for the form and creates the
<strong>courseViewer _Load</strong> event handler method.</li>
      <li>In the <strong>courseViewer _Load</strong> event handler method, copy
and paste the following code that defines the <strong>DataGridView</strong>, executes a query
that returns a collection of departments (ordered by <strong>Name</strong>), and binds the
collection of <strong>Department</strong> objects to the departmentList control.
<div>
          <pre class="programlisting">
Visual Basic

&#39; Initialize the ObjectContext.
schoolContext = New SchoolEntities()

&#39; Define a query that returns all Department objects and related
&#39; Course objects, ordered by name.
Dim departmentQuery As ObjectQuery(Of Department) = _
    schoolContext.Department.Include(&quot;Course&quot;).OrderBy(&quot;it.Name&quot;)

Try
    &#39; Bind the ComboBox control to the query, which is
    &#39; executed during data binding.
    Me.departmentList.DisplayMember = &quot;Name&quot;
    Me.departmentList.DataSource = departmentQuery
Catch ex As Exception
    MessageBox.Show(ex.Message)
End Try

C#

// Initialize the ObjectContext.
schoolContext = new SchoolEntities();

// Define a query that returns all Department objects and related
// Course objects, ordered by name.
ObjectQuery&lt;Department&gt; departmentQuery =
    schoolContext.Department.Include(&quot;Course&quot;).OrderBy(&quot;it.Name&quot;);

try
{
    // Bind the ComboBox control to the query, which is
    // executed during data binding.
    this.departmentList.DisplayMember = &quot;Name&quot;;
    this.departmentList.DataSource = departmentQuery;
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}
</pre>
        </div>
          </li>
    </ol>
        <p>
      <strong>Display courses for the selected department</strong>
    </p>
        <ol>
      <li>In the <strong>CourseViewer</strong> form designer, double-click the
<strong>departmentList</strong> control. This creates the <strong>departmentList_SelectedIndexChanged</strong> event handler method.</li>
      <li>Paste the following code that loads the courses that are related to the selected department.
<div>
          <pre class="programlisting">
Visual Basic

Try
    &#39; Get the object for the selected department.
    Dim department As Department = _
        CType(Me.departmentList.SelectedItem, Department)

    &#39; Bind the grid view to the collection of Course objects
    &#39; that are related to the selected Department object.
    courseGridView.DataSource = department.Course

    &#39; Hide the columns that are bound to the navigation properties on Course.
    courseGridView.Columns(&quot;Department&quot;).Visible = False
    courseGridView.Columns(&quot;CourseGrade&quot;).Visible = False
    courseGridView.Columns(&quot;OnlineCourse&quot;).Visible = False
    courseGridView.Columns(&quot;OnsiteCourse&quot;).Visible = False
    courseGridView.Columns(&quot;Person&quot;).Visible = False

    courseGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells)
Catch ex As Exception
    MessageBox.Show(ex.Message)
End Try

C#

try
{
    // Get the object for the selected department.
    Department department =
        (Department)this.departmentList.SelectedItem;

    // Bind the grid view to the collection of Course objects
    // that are related to the selected Department object.
    courseGridView.DataSource = department.Course;

    // Hide the columns that are bound to the navigation properties on Course.
    courseGridView.Columns[&quot;Department&quot;].Visible = false;
    courseGridView.Columns[&quot;CourseGrade&quot;].Visible = false;
    courseGridView.Columns[&quot;OnlineCourse&quot;].Visible = false;
    courseGridView.Columns[&quot;OnsiteCourse&quot;].Visible = false;
    courseGridView.Columns[&quot;Person&quot;].Visible = false;

    courseGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}
</pre>
        </div>
            </li>
    </ol>
        <br />
        
          <a name="installvsentinsertandupdate" />
    <h3>2.7.5. Inserting and Updating Data</h3>
          <p>In this section the changes made to Course objects bound are saved to the DataGridView control to the database and also run the completed Course Manager application.</p>
          <p>
      <strong>Save changes made to objects</strong>
    </p>
          <ol>
      <li>In the <strong>Toolbox</strong>, expand <strong>Common Controls</strong>,
drag the <strong>Button</strong> control to the <strong>CourseViewer</strong> form designer,
change the <strong>name</strong> of the control to <strong>saveChanges</strong>, and change the
<strong>Text</strong> value to <strong>Update</strong>.</li>
      <li>In the <strong>CourseViewer</strong> form designer, double-click the
<strong>saveChanges</strong> control. This creates the <strong>saveChanges_Click</strong> event handler method.
            </li>
      <li>Paste the following code that saves object changes to the database.
<div>
          <pre class="programlisting">
Visual Basic

Try
    &#39; Save object changes to the database, display a message,
    &#39; and refresh the form.
    schoolContext.SaveChanges()
    MessageBox.Show(&quot;Changes saved to the database.&quot;)
    Me.Refresh()
Catch ex As Exception
    MessageBox.Show(ex.Message)
End Try

C#

try
{
    // Save object changes to the database, display a message,
    // and refresh the form.
    schoolContext.SaveChanges();
    MessageBox.Show(&quot;Changes saved to the database.&quot;);
    this.Refresh();
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}
</pre>
        </div>
            </li>
      <li>In the <strong>closeForm_Click</strong> event handler method, type the
following code. This code disposes of the object context before the form is closed.
<div>
          <pre class="programlisting">
Visual Basic

   &#39; Dispose the object context.
    schoolContext.Dispose()

C#

    // Dispose the object context.
    schoolContext.Dispose();
</pre>
        </div>
          </li>
    </ol>
        <p>
      <strong>Build and run the Class Scheduling application</strong>
    </p>
        <ol>
      <li>From the <strong>Debug</strong> menu, select
<strong>Start Debugging</strong> or <strong>Start Without Debugging</strong>, to build and
run the application.</li>
      <li>When the form loads, select a department from the <strong>ComboBox</strong>
control to display the courses that belong to that department.
          <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="ComboBox" src="../images/ui/uado18.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.5.1. ComboBox</td>
      </tr>
        </table>
        </li>
      <li>In the <strong>DataGridView</strong>, update course information or add a
new course and then click <strong>Update</strong> to save changes to the database and displays a
message box that declares the number of saved changes.
          <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="DataGridView" src="../images/ui/uado19.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.7.5.1. DataGridView</td>
      </tr>
        </table>
        </li>
    </ol>
      <p>The process is now complete</p>
    <br />
  <table border="0" width="90%" id="navbarbottom">
    <tr>
        <td align="left" width="33%">
          <a href="installvsgrid.html" title="Virtuoso ADO.Net Data Grid Form Application">Previous</a>
          <br />Virtuoso ADO.Net Data Grid Form Application</td>
     <td align="center" width="34%">
          <a href="installation.html">Chapter Contents</a>
     </td>
        <td align="right" width="33%">
          <a href="installusado.html" title="Using Visual Studio 2008 to Build an ADO.NET Data Services based Application">Next</a>
          <br />Using Visual Studio 2008 to Build an ADO.NET Data Services based Application</td>
    </tr>
    </table>
  </div>
  <div id="footer">
    <div>Copyright© 1999 - 2009 OpenLink Software All rights reserved.</div>
   <div id="validation">
    <a href="http://validator.w3.org/check/referer">
        <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" />
    </a>
    <a href="http://jigsaw.w3.org/css-validator/">
        <img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" />
    </a>
   </div>
  </div>
 </body>
</html>