Download presentation
Presentation is loading. Please wait.
Published byAlexina Roberts Modified over 9 years ago
1
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 25 I’m Suffering from Information Overload
2
Clearly Visual Basic: Programming with Visual Basic 2008 Objectives Define the terms used when talking about databases Connect an application to a Microsoft Access database Bind table and field objects to controls Customize a DataGridView control Handle exceptions using the Try…Catch statement Position the record pointer in a dataset 2
3
Clearly Visual Basic: Programming with Visual Basic 2008 Keeping Good Records Computer database –Electronic file that contains an organized collection of related information Relational database –Stores information in tables composed of columns and rows Field –Single item of information about a person, place, or thing 3
4
Clearly Visual Basic: Programming with Visual Basic 2008 Keeping Good Records (continued) Record –Group of related fields that contain all the necessary data about a specific person, place, or thing Table –Group of related records Primary key –Field that uniquely identifies each record in a table 4
5
Clearly Visual Basic: Programming with Visual Basic 20085
6
Keeping Good Records (continued) Figure 25-2 –CD_Number field Primary key in parent table –CD_Number field in child table Used solely to link song title and track information to the appropriate CD in parent table –Child table CD_Number field is called the foreign key 6
7
Clearly Visual Basic: Programming with Visual Basic 20087
8
Connecting … Connecting Figure 25-3 –Emp_Number field is the primary key –Status field contains the employment status –Code field identifies the employee’s department Data Source Configuration Wizard –Easiest way to connect an application to a database 8
9
Clearly Visual Basic: Programming with Visual Basic 20089
10
Let the Computer Do It Binding –Connecting an object to a control Bound controls –The connected controls DataGridView control –Displays data in row and columnar format, similar to a spreadsheet –One of the most popular controls for displaying table data 10
11
Clearly Visual Basic: Programming with Visual Basic 200811
12
Clearly Visual Basic: Programming with Visual Basic 2008 Let the Computer Do It (continued) While an application is running, you can use the BindingNavigator control to: –Move from one record to the next in the dataset –Add or delete a record and save any changes made to the dataset Component tray –Stores objects that do not appear in the user interface while an application is running TableAdapter object in the component tray –Connects the database to the DataSet object 12
13
Clearly Visual Basic: Programming with Visual Basic 2008 Let the Computer Do It (continued) TableAdapterManager object –Used to save changes made to the database BindingSource object –Provides the connection between the DataSet and the bound controls on the Form TblEmployBindingSource in Figure 25-7 –Connects EmployeesDataSet to two bound controls DataGridView control and BindingNavigator control Figure 25-8 –Shows relationship between database, DataSet, and Form 13
14
Clearly Visual Basic: Programming with Visual Basic 200814
15
Clearly Visual Basic: Programming with Visual Basic 200815
16
Clearly Visual Basic: Programming with Visual Basic 2008 The Copy to Output Directory Property When the Data Source Configuration Wizard connects an application to a database: –It adds the database file to the application’s project folder Method of saving changes to a local database file –Is determined by the file’s Copy to Output Directory property 16
17
Clearly Visual Basic: Programming with Visual Basic 2008 How Does Visual Basic Do It? When a table or field object is dragged to the form: –Computer adds the appropriate controls and objects to the application A form’s Load event –Occurs when the application is started and the form is displayed for the first time Load event procedure –Code to fill a dataset with data belongs here 17
18
Clearly Visual Basic: Programming with Visual Basic 2008 Thank You for Catching My Errors Exceptions –Handled in Visual Basic by displaying an error message and then abruptly terminating the application Try…Catch statement –Used to take control of the exception handling in your code 18
19
Clearly Visual Basic: Programming with Visual Basic 200819
20
Clearly Visual Basic: Programming with Visual Basic 2008 I’ll Use My Own Controls, Thank You To bind an object in a dataset to an existing control on the form: –Drag the object from the Data Sources window to the control BindingSource object –Uses an invisible record pointer to keep track of the current record in the dataset Position property –Stores the position of the record pointer 20
21
Clearly Visual Basic: Programming with Visual Basic 200821
22
Clearly Visual Basic: Programming with Visual Basic 200822
23
Clearly Visual Basic: Programming with Visual Basic 200823
24
Clearly Visual Basic: Programming with Visual Basic 2008 Summary Relational database can contain one or more tables Data in a relational database –Can be displayed in any order Most tables contain a primary key that uniquely identifies each record To access the data stored in a database: –First connect the application to the database You display the information contained in a dataset by: –Binding one or more of the dataset objects to one or more controls in the application’s interface 24
25
Clearly Visual Basic: Programming with Visual Basic 2008 Summary (continued) TableAdapter object –Connects a database to a DataSet object DataGridView control –Displays data in a row and columnar format Try…Catch statement –Used to handle exceptions that occur while an application is running BindingSource object –Uses an invisible record pointer to keep track of the current record in a dataset 25
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.