Microsoft Visual Basic 2010 Step by Step eBook

(Tina Meador) #1

466 Part IV Database and Web Programming


Since the names are listed alphabetically from A to Z, Zimprich is now last in the list of
faculty members.


  1. Scroll through the remainder of the records, and then verify that it is now in ascending
    alphabetical order.

  2. Click the Close button to end the program.


You’re on your way with building custom queries by using SQL statements and Query Builder.
Database programming is a complex topic, but you have already learned much that will help
you build datacentric applications—highly personalized collections of data that benefit the
user and his or her computing needs—in Visual Basic. You will continue exploring the theme
of rich data access in Chapter 19. And in Chapter 20, your final project will be displaying
database records on a Web site.

Chapter 18 Quick Reference


To Do This
Establish a connection
to a database

Click the Add New Data Source command on the Data menu, and then
use the Data Source Configuration Wizard to browse to the database you
want to provide access for by building a connection string.
Create a dataset Using the Data Source Configuration Wizard, specify a name for the
dataset in the DataSet Name box, expand the Tables node in the tree
view of your database presented by the wizard, and then specify the
tables and fields that you want to include in your dataset. (A dataset
need not include all database tables and fields .)
Create bound objects
capable of displaying
data from a dataset
on a Windows form

After running the Data Source Configuration Wizard, open the Data
Sources window, and drag tables, fields, or both to the Windows form.
To control the type of bound control created by Visual Studio for a
table or field, click its arrow and select a control from the list box before
dragging it. If you placed a control on the form before adding data sources
to the project, bind a database object to the control by dragging the
database objects from the Data Sources window onto the control on the
form. Alternatively, set an object’s DataBinding properties to a valid field
(column) in the dataset. (One of the most useful DataBinding properties
is Text .)
Add navigation controls
to a Windows form

When a valid database object is dragged from the Data Sources window
to a Windows form in the Designer, a navigation toolbar is added
automatically to the form. To customize the buttons on this toolbar,
right-click the BindingNavigator object in the component tray, and then
click Edit Items.
Format database
information on a form

Use a MaskedTextBox control to format the content of string data in
the dataset. The MaskedTextBox control offers many useful input masks
and the ability to create custom string formats.
Filter or sort database
information stored
in a dataset

Use SQL statements to create custom queries in the Visual Studio Query
Builder, and then add these queries to a toolbar on a Windows form.
After you master Query Builder, you’ll be ready to experiment with LINQ.
Free download pdf