Lecture Learning programming using Visual Basic Net – Chapter 8 Accessing data processing databases

25 235 0
Lecture Learning programming using Visual Basic Net – Chapter 8 Accessing data  processing databases

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

The following will be discussed in this chapter Data is efficiently managed by storing them in files on disk, data files and programs are separate, the program does not need to be modified when the data changes, different programs can share the same data sets.

CHAPTER EIGHT Accessing Data Processing Databases 8- Introduction • Data is efficiently managed by storing them in files on disk • Data files and programs are separate • The program does not need to be modified when the data changes • Different programs can share the same data sets McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 8- Introduction (cont.) • Most businesses organize their data into databases • A database is an organizes collection of data • A database management system (DBMS) is a program that is used to create and maintain databases • Visual Basic NET provides tools for developers to access databases from their programs McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 8- Objectives • Understand and use relational databases • Understand a subset of the ADO.NET object model • Apply the ADO.NET object model within Visual Basic NET to access databases • Use the properties and methods of the DataGrid control to display record from a DataSet McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 8- Objectives (cont.) • Write SQL Select queries to extract data from a database • Bind controls such as TextBoxes and Labels to a DataSet • Create Master/Detail DataSets • Use several tools within Visual Basic NET to manage and use databases McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 8- 8.1 A Relational Database Primer • Entities and Relationships – Every database contains: • Entities – anything of interest to a business • Relationships – real-world associations between entities – Database developers often use an entityrelationship diagram (ERD) • To document a database’s structure • Symbols are used to designate relationships between entities McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 8- 8.1 A Relational Database Primer (cont.) • Relational Database Tables – A relational database stores the data for each entity in a table with rows and columns – Compatible with Visual Basic NET – A key field guarantees the uniqueness of records – A combination key is a key field with a combination of two or more fields McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 8- 8.1 A Relational Database Primer (cont.) – One-to-Many Relationships • Established by placing the key field of the “one” entity’s table into the “many” entity’s table as a foreign key – Many-to-Many Relationships • Constructed by creating a new table with the key fields from related tables McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 8- 8.1 A Relational Database Primer (cont.) – Normalized Databases • Normalization is a process used to eliminate or reduce data redundancy • Designers must determine which tables to place information in • A table should be in third normal form McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 8.1 A Relational Database Primer (cont.) • Database Queries – Most relational database systems use a query language called structured query language (SQL) • To specify how to combine data in related tables • To specify how to select only the desired data McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 810 8.2 An Introduction to ADO.NET • Visual Basic NET uses ADO.NET to manage data in a database – ADO.NET (ActiveX Data Objects) uses an extensive set of classes to manage data – This chapter covers the foundations of ADO.NET – Also we will cover some of the wizards and tools provided to work with relational databases McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 811 8.2 An Introduction to ADO.NET (cont.) • An Overview of ADO.NET – A DataProvider object directly interacts with a database and its DBMS – A Connection object makes the physical connection to the database – A DataSet class holds the actual data – User interface components work directly with the DataSet McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 812 8.3 Using ADO.NET with Visual Basic NET • Data Access Using the DataGrid Control – Provides a method of displaying records from a database in a grid-like manner – Building the DataAdapter • Create a DataAdapter by a wizard – Building the DataSet • Follow the procedure to create a DataSet McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 813 8.3 Using ADO.NET with Visual Basic NET (cont.) – Adding the DataGrid • Follow the procedure to add a DataGrid to the form • Set the DataGrid properties to connect it to the DataAdapter and DataSet • Found on the Windows Form tab in the Toolbox • Will display fields specified in the SQL Select statement McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 814 8.3 Using ADO.NET with Visual Basic NET (cont.) • The DataGrid Control – Designed to display the data stored in a DataSet – An expander allows navigation from a parent table to a child table McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 815 8.3 Using ADO.NET with Visual Basic NET (cont.) – Properties AllowSorting AlternatingBackColor BackColor BackgroundColor BorderStyle CaptionBackColor CaptionFont CaptionForeColor CaptionText CaptionVisible ColumnHeadersVisible McGraw Hill/Irwin CurrentCell CurrentRowIndex DataMember DataSource Enabled FirstVisibleColumn ForeColor GridLineColor GridLineStyle HeaderBackColor HeaderFont ©2002 by The McGraw-Hill Companies, Inc All rights reserved 816 8.3 Using ADO.NET with Visual Basic NET (cont.) – Properties (cont.) HeaderForeColor ParentRowsBackColor ParentRowsForeColor ParentRowsVisible PreferredColumnWidth ReadOnly RowHeadersVisible RowHeaderWidth SelectionBackColor SelectionForeColor McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 817 8.3 Using ADO.NET with Visual Basic NET (cont.) – Methods • • • • • • Collapse(row) Expand(row) IsExpanded(row) IsSelected(row) Select(row) SetDataBinding(dataSourceObject, dataMemberString) • UnSelect(row) McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 818 8.3 Using ADO.NET with Visual Basic NET (cont.) • Updating a Table – ADO.NET provides support for table update – Changes in the DataGrid can be relayed back to the original source data McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 819 8.3 Using ADO.NET with Visual Basic NET (cont.) • Parameterized Queries – Users will often want to specify information that will determine the results of a query – A parameter of a query could be a zipcode McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 820 8.3 Using ADO.NET with Visual Basic NET (cont.) • Master/Detail Record Display – Here we examine a DataSet that includes two tables related to a common field – A master/detail DataSet is a dataset with more than one table – Each master record is related to zero or more records from the second table – Parent and child terms may refer to master and detail records McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 821 8.4 Additional Visual Basic NET Database Tools • We look at using the Server to work with databases • We show how to add a data connection to the server • The data connection will be used to create a data adapter and data set McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 822 Chapter Summary • A database is an organized collection of data and relationships that describe entities of interest to a business • An entity-relationship diagram (ERD) documents entities and their relationships • Visual Basic NET supports the relational database approach for organizing data • Normalization is process used to minimize data redundancy McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 823 Chapter Summary (cont.) • Visual Basic NET uses ADO.NET to access and manage databases • The DataGrid control is a control that can be bound to a specific dataset • Parameterized queries provide for the ability to determine how records will be selected at run time • Many of Visual Basic NET’s controls can be bound to a dataset and its fields McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 824 Chapter Summary (cont.) • ADO.NET supports master/detail record relationships • The Server Explorer provides access and management tools for connections and servers McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc All rights reserved 825 ... Visual Basic NET uses ADO .NET to manage data in a database – ADO .NET (ActiveX Data Objects) uses an extensive set of classes to manage data – This chapter covers the foundations of ADO .NET – Also... The McGraw-Hill Companies, Inc All rights reserved 81 2 8. 3 Using ADO .NET with Visual Basic NET • Data Access Using the DataGrid Control – Provides a method of displaying records from a database... reserved 81 3 8. 3 Using ADO .NET with Visual Basic NET (cont.) – Adding the DataGrid • Follow the procedure to add a DataGrid to the form • Set the DataGrid properties to connect it to the DataAdapter

Ngày đăng: 16/05/2017, 14:41

Từ khóa liên quan

Mục lục

  • CHAPTER EIGHT

  • Introduction

  • Introduction (cont.)

  • Objectives

  • Objectives (cont.)

  • 8.1 A Relational Database Primer

  • 8.1 A Relational Database Primer (cont.)

  • Slide 8

  • Slide 9

  • Slide 10

  • 8.2 An Introduction to ADO.NET

  • 8.2 An Introduction to ADO.NET (cont.)

  • 8.3 Using ADO.NET with Visual Basic .NET

  • 8.3 Using ADO.NET with Visual Basic .NET (cont.)

  • Slide 15

  • Slide 16

  • Slide 17

  • Slide 18

  • Slide 19

  • Slide 20

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan