Microsoft Visual Basic 2010 Step by Step eBook

(Tina Meador) #1

Chapter 18 Getting Started with ADO .NET 461


Importantly, the masked text box object correctly formats the phone number
information so that it is in the expected format for North American phone numbers.


  1. Click the Move Next button a few times.


Another important feature is also demonstrated here: The two dataset fields scroll
together, and the displayed faculty names match the corresponding business phone
numbers recorded in the Faculty2010 database. This synchronization is handled by
the FacultyBindingNavigator object, which keeps track of the current record for each
bound object on the form.


  1. Click the Close button to stop the program, and then click the Save All button to save
    your changes.
    You’ve learned to display multiple database fields on a form, use the navigation toolbar to
    browse through a dataset, and format database information with a mask. Before you leave
    this chapter and move on to the useful DataGridView control discussed in Chapter 19, take
    a moment to see how you can further customize your dataset by using a few SQL statements.


One Step Further: SQL Statements, LINQ,


and Filtering Data


You have used the Data Source Configuration Wizard to extract just the table and
fields you wanted from the Faculty2010 database by creating a custom dataset named
Faculty2010DataSet. In addition to this filtering, however, you can further organize
and fine-tune the data displayed by bound controls by using SQL statements and the Visual
Studio Query Builder. This section introduces these tools.

For Visual Basic users who are familiar with Access or SQL Server, filtering data with
SQL statements is nothing new. But the rest of us need to learn that SQL statements
are commands that extract, or filter, information from one or more structured tables
in a database. The reason for this filtering is simple: Just as Web users are routinely
confronted with a bewildering amount of data on the Internet (and use clever search
keywords in their browsers to locate just the information they need), database
programmers are routinely confronted with tables containing tens of thousands of records
that need refinement and organization to accomplish a particular task. The SQL SELECT
statement is one traditional mechanism for organizing database information. By chaining
together a group of these statements, programmers can create complex search directives,
or queries, that extract just the data that is needed from a database.

Realizing the industry-wide acceptance of SQL statements, previous versions of the Visual
Studio and Visual Basic IDEs have included mechanisms for using SQL statements. In addition,
Visual Studio 2008 and 2010 offer a powerful technology called Language-Integrated Query
(LINQ), which allows experienced programmers to write SQL-styled database queries directly
Free download pdf