Chapter 12 Homework Solutions
Transcript of Chapter 12 Homework Solutions
-
7/31/2019 Chapter 12 Homework Solutions
1/3
Chapter 12 Homework Solutions:
-
7/31/2019 Chapter 12 Homework Solutions
2/3
Chapter 12-Advanced Data HandlingGrids, Validation, Selection, and SQL
ANSWERS TO REVIEW QUESTIONS
1. When would it be a good idea to use a grid control?
It is useful to use a grid control when adding, changing, and deleting data in tables. A grid
control displays the data in rows and columns. Each cell(intersection of a row andcolumn) acts like a text box.
2. When does a controls Validate event occur? How is the Cancel argument used?
The Validate event occurs for the control just before it loses the focus. In the Validate
event procedure, you can perform any error checking and display a message for the user. If
the data doesnt pass the error checking, set Cancel to True. When the sub procedure
completes, the focus will remain in the control you are checking.
3. Explain the differences among tables, dynasets, and snapshots.
Visual Basic supports three kinds of recordsets; tables, dynasets, and snapshots. Table
recordsets and dynasets are usually updateable, unless the file is locked or it is opened for
ReadOnly. Snapshots represent an unchangeable picture of the data at one point in time.
A table recordset represents a single table, as it exists in a database file A dynaset is a
temporary set of data, taken from one or more tables in the underlying file. A dynaset may
be a query that was defined in an Access database, a single table, a subset of a table, or the
result of joining multiple tables.
A table recordset represents a single table as it exists in a database file. A snapshot
recordset, like a dynaset, may be taken from one or more tables. The differences are that a
snapshot is not updateable and also not "live." You can think of a snapshot recordset like a
photographa picture of reality at a given point in time.
4. For which type(s) of recordsets is a Find valid (FindFirst, FindNext, FindLast, or
FindPrevious)? What types of data can be searched for with a Find?
The Find methods may be used on a dynaset or a snapshot recordset, but not on a tablerecordset A Find method may be used to search for any data in any field bound to one of
your controls.
5. For which type(s) of recordsets is a Seek valid? Which fields in a recordset can be
searched with a Seek?
Seek is only valid for table recordsets. In order to do a Seek, the field (or fields) on which
you search must be defined with an index. Using indexes for the search is much faster than
checking every record in the table as in a Find. Before you can Seek, you must first set the
Recordset's Index property to the name of an index in your table. In an Access table, the
index on the primary key is called "PrimaryKey." If there are other indexes defined in the
table, usually the index name is the same as the field name. Using the Learning Edition of
Visual Basic and the data control, you can only use indexes already defined in the database;with the Professional or Enterprise edition, you can create your own indexes at run time.
6. What is SQL, and how is it used in Visual Basic?
Visual Basic uses SQL (structured query language) to create new dynasets. SQL
(pronounced either "sequel" or "S," "Q," "L") is an industry-standard language for
accessing relational databases. In this text we use SQL to select fields and records from a
table, and to join the fields from two tables.
-
7/31/2019 Chapter 12 Homework Solutions
3/3