Databases and ADO.NET Programming Right from the Start with Visual Basic.NET 1/e 11.

Slides:



Advertisements
Similar presentations
Data Base. Objective Become familiar with database terminology. Create a project to display data for a single database table. Use a DataGrid control.
Advertisements

Chapter 10 Database Applications Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
 Open the Paradise.exe file  Application displays records in the Books database  Allows the store manager to enter an author’s name (or part of a name)
Pasewark & Pasewark Microsoft Office XP: Introductory Course 1 INTRODUCTORY MICROSOFT ACCESS Lesson 4 – Finding and Ordering Data.
Concepts of Database Management Seventh Edition
Concepts of Database Management Sixth Edition
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 1 Committed to Shaping the Next Generation of IT Experts. Chapter 2: Relational Databases.
Chapter 12: Using ADO.NET 2.0 Programming with Microsoft Visual Basic 2005, Third Edition.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
Using ADO.NET Chapter Microsoft Visual Basic.NET: Reloaded 1.
Introduction to Data Adapter. A Simplified View of ADO.Net Objects Ado.Net Data Provider Connection Adapter Command Reader Dataset Data Consumer WinForm.
VB.NET Database Access ISYS 812. Microsoft Universal Data Access ODBC: Open Database Connectivity –A driver manager –Used for relational databases OLE.
1 Pertemuan 09 Database Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
Chapter 14: Advanced Topics: DBMS, SQL, and ASP.NET
Chapter 12 Database Connectivity with ASP.NET JavaScript, Third Edition.
1 Chapter 2 Reviewing Tables and Queries. 2 Chapter Objectives Identify the steps required to develop an Access application Specify the characteristics.
Chapter Extension 6 Using Microsoft Access © 2008 Pearson Prentice Hall, Experiencing MIS, David Kroenke.
Microsoft Access 2010 Chapter 7 Using SQL.
MMG508.  Access Types  Tables  Relational tables  Queries  Stored database queries  Forms  GUI forms for data entry/display  Reports  Reports.
From VS C# 2010 Programming, John Allwork 1 VS2010 C# Programming - DB intro 1 Topics – Database Relational - linked tables SQL ADO.NET objects Referencing.
1 Access Lesson 3 Creating Queries Microsoft Office 2010 Introductory Pasewark & Pasewark.
Some Basic Database Terminology
Chapter 10 - VB.Net by Schneider1 Chapter 10 – Database Management 10.1 An Introduction to Databases 10.2 Relational Databases and SQL.
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 1 1. Chapter 2: Relational Databases and Multi-Table Queries Exploring Microsoft Office.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
Programming with Visual Basic.NET An Object-Oriented Approach  Chapter 8 Introduction to Database Processing.
Introduction –All information systems create, read, update and delete data. This data is stored in files and databases. Files are collections of similar.
Copyright © 2003 by Prentice Hall Computers: Tools for an Information Age Chapter 13 Database Management Systems: Getting Data Together.
ASP.NET Programming with C# and SQL Server First Edition
Introduction to ADO.Net and Visual Studio Database Tools ISYS 512.
1 Lesson 6 — Database Programming Microsoft Visual Basic.NET, Introduction to Programming.
Copyright © 2008 Pearson Prentice Hall. All rights reserved.1 1 Committed to Shaping the Next Generation of IT Experts. Chapter 2: Relational Databases.
CHAPTER 7 Database: SQL, MySQL. Topics  Introduction  Relational Database Model  Relational Database Overview: Books.mdb Database  SQL (Structured.
With Microsoft Office 2007 Introductory© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Introductory.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
DAY 14: ACCESS CHAPTER 1 Tazin Afrin October 03,
1 Chapter 1 Overview of Database Concepts. 2 Chapter Objectives Identify the purpose of a database management system (DBMS) Distinguish a field from a.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Twelve Access Databases and LINQ.
Microsoft Access 2003 Define some key Access terminology: Field – A single characteristic or attribute of a person, place, object, event, or idea. Record.
CHAPTER 8: MANAGING DATA RESOURCES. File Organization Terms Field: group of characters that represent something Record: group of related fields File:
RELATIONSHIPS Generally there are two main database types: flat-file and relational.
CHAPTER EIGHT Accessing Data Processing Databases.
CHAPTER EIGHT Accessing Data Processing Databases.
Concepts of Database Management Seventh Edition
6.1 © 2010 by Prentice Hall 6 Chapter Foundations of Business Intelligence: Databases and Information Management.
Using Adapter Wizard ISYS 512. Data Adapter Wizard – 2 nd Level of Using ADO.Net Configure Data Adapter and generating a dataset: –From the Data tab of.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Chapter Thirteen Working with Access Databases and LINQ Programming with Microsoft Visual Basic th Edition.
CSCI 3327 Visual Basic Chapter 13: Databases and LINQ UTPA – Fall 2011.
Mauricio Featherman, Ph.D. Washington St. University
Pasewark & Pasewark Microsoft Office 2003: Introductory 1 INTRODUCTORY MICROSOFT ACCESS Lesson 4 – Finding and Ordering Data.
Lesson 13 Databases Unit 2—Using the Computer. Computer Concepts BASICS - 22 Objectives Define the purpose and function of database software. Identify.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 25 I’m Suffering from Information Overload.
1 Chapter 10 – Database Management 10.1 An Introduction to Databases 10.2 Editing and Designing Databases.
Chapter 24 I’m Suffering from Information Overload (Access Databases) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Chapter 9 Vocabulary Databases. 1.Table – a collection of information, or data arranged in columns and rows. 2.Record – all of the information about one.
Database Connectivity with ASP.NET. 2 Introduction Web pages commonly used to: –Gather information stored on a Web server database Most server-side scripting.
CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg,
ADO.NET Objects Data Adapters Dr. Ron Eaglin. Agenda Builds on Information in Part I Should have working knowledge of creating a database connection Continuation.
Introduction to ADO.Net and Visual Studio Database Tools ISYS 350.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
1 Access Lesson 1 Understanding Access Fundamentals Microsoft Office 2010 Fundamentals Story / Walls.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
XP Chapter 1 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Level 2 Objectives: Understanding and Creating Table.
Microsoft Visual Basic 2010: Reloaded Fourth Edition
Databases and Information Management
VB.NET Using Database.
Database Applications
Working With Databases
Chapter 10 Accessing Database Files
Presentation transcript:

Databases and ADO.NET Programming Right from the Start with Visual Basic.NET 1/e 11

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 2 Objectives Understand databases and the relational database model Understand primary keys and foreign keys Understand simple SQL queries Use WHERE and ORDER BY clauses Query multiple tables using JOIN Create a Connection object

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 3 Objectives (cont.) Create and work with a DataAdapter object Create and work with a Dataset object Work with data bound controls Work with the DataGrid control Develop applications that interact with a database

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall Database Primer A database is a structured collection of data. A field is a storage location for a single piece of information. A record is a complete collection of related fields. A table is a complete set of related records.

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall Database Primer (cont.)

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 6 Relational Databases In the relational database model, relationships exist between tables to indicate how the data is connected. Relationships involve the primary key from one table and a foreign key in a related table.

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 7 Relational Databases (cont.) The primary key is a field (or set of fields) that uniquely distinguishes the records in a table. The foreign key contains values that match primary key values in a related table. The primary key and foreign key fields are essential for creating the relationships between tables.

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 8 Relational Databases (cont.)

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 9 Relational Databases (cont.)

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 10 Relational Databases (cont.) The Customers table and the Orders table have a one-to-many relationship. Students and Classes have a many-to-many relationship. A many-to-many relationship is usually implemented using a linking table with foreign keys to each of the two original tables.

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall Structured Query Language (SQL) An application communicates with a DBMS through queries written in a standard language called Structured Query Language (SQL). SQL is an industry standard language that allows an application to communicate with a relational database.

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 12 SELECT Query The SELECT command is used to select specific information from one or more tables in a database. –SELECT fields FROM table

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 13 WHERE Clause The WHERE clause provides the database the capability to choose information based on selection criteria. –SELECT fields FROM table WHERE criteria The WHERE clause condition can contain >,, >=, <= LIKE, *, and ? can also be used

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 14 ORDER BY Clause The information returned by a SELECT statement can be arranged in ascending or descending order with the ORDER BY clause. –SELECT fields FROM table [WHERE criteria] ORDER BY field [ASCIDESC] ASC specifies ascending order; DESC specifies descending order.

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 15 JOIN To create a query that combines data from multiple tables, you use the JOIN operation. –SELECT fields FROM table1 [LEFT|RIGHT] JOIN table2 ON table1.field1 = table2.field2 [WHERE criteria] [ORDER BY field]

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall Using ADO.NET ADO.NET is the data access architecture for the.NET Framework. ADO.NET provides Connection, Data- Adapter, and Dataset objects to facilitate accessing data in a database.

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall Using ADO.NET (cont.)

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 18 Creating a Connection A Connection object establishes a link from your application to a database file. A connection object specifies the type and location of the database file. Step 1: Create a Connection is to select an OleDbConnection control from the Toolbox

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 19 Creating a Connection (cont.) Step 2: Create a Connection is to add an OleDbConnection object to the component tray. Step 3: Select a New Connection for the control. Step 4: Select the appropriate database provider and the path/filename of the database.

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 20 Creating a DataAdapter Once a Connection has been established, the next step is to create a DataAdapter. A DataAdapter passes information between the database and your application. The SQL command is part of the DataAdapter.

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 21 Creating a DataAdapter (cont.) Step 1: Add an OleDbAdapter control which starts a Wizard Step 2: Specify the Connection to use for the DataAdapter Step 3: Select a Query Type Step 4: Specify the SQL statements Step 5: Save the settings

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 22 Creating a DataAdapter (cont.)

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 23 Generating a Dataset Once you have established a Connection and a DataAdapter, the next step is to create a Dataset. A Dataset in ADO.NET is a temporary, local copy of the information in the table. To create a Dataset, right-click on the object and select Generate Dataset from the pop-up menu.

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall Displaying and Navigating Records The information in a Dataset can be viewed by means of one or more data-aware controls. A data-aware control is a control that can be bound to a Dataset; when bound, the control automatically displays the information it receives from the Dataset.

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 25 The Fill Method The Fill method of the DataAdapter is used to populate the Dataset. –DataAdapter.Fill(DataSet)

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 26 Dataset Navigation When text boxes are data bound they display their specified field values for the current record in the specified dataset. Each form has a BindingContext object that keeps track of all the data sources associated with the form. The BindingContext has a position property and a Count property.

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall The DataGrid Control The DataGrid control is designed to display ADO.NET data in a scrollable grid. The DataSource property specifies the name of the data source from which the grid will get data. The DataMember property specifies which table or other element to bind to if the data source contains more than one bindable element.

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 28 Chapter Summary A database is a collection of one or more structured sets of data. A table is a two-dimensional matrix of rows and columns. A foreign key is a field in a table that refers to the primary key in another table.

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 29 Chapter Summary (cont.) An application communicates with a DBMS through queries written in SQL. The SELECT command is used to select specific information from one or more tables in a database. The WHERE clause is used to choose information based on selection criteria.

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 30 Chapter Summary (cont.) The results of a query can be arranged in ascending or descending order with the ORDER BY clause. Relational databases store data over multiple tables to eliminate data redundancy. A Connection object establishes a link from your application to a database and specifies the type and location of the database.

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 31 Chapter Summary (cont.) Once a Connection has been established, the next step is to create a DataAdapter. Once a Connection and a DataAdapter have been established, the next step is to create a Dataset. A Data-aware control is a control that can be bound to a Dataset.

Crews/Murphy – Programming Right from the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 32 Chapter Summary (cont.) Each form has a BindingContext object that keeps track of all the data sources associated with the form. The DataGrid control is designed to display ADO.NET data in a scrollable grid.

Databases and ADO.NET Programming Right from the Start with Visual Basic.NET 1/e 11