Download presentation
Presentation is loading. Please wait.
Published byRose Francis Modified over 9 years ago
1
2006 Pearson Education, Inc. All rights reserved. 1 20 Database, SQL and ADO.NET
2
2006 Pearson Education, Inc. All rights reserved. 2 It is a capital mistake to theorize before one has data. — Arthur Conan Doyle Now go, write it before them in a table, and note it in a book, that it may be for the time to come for ever and ever. — Holy Bible, Isaiah 30:8 Get your facts first, and then you can distort them as much as you please. — Mark Twain I like two kinds of men: domestic and foreign. — Mae West
3
2006 Pearson Education, Inc. All rights reserved. 3 OBJECTIVES In this chapter you will learn: The relational database model. To write basic database queries in SQL. To add data sources to projects. To use the IDE's drag-and-drop capabilities to display database tables in applications. To use the classes of namespaces System.Data and System.Data.SqlClient to manipulate databases. To use ADO.NET's disconnected object model to store data from a database in local memory. To create XML documents from data sources.
4
2006 Pearson Education, Inc. All rights reserved. 4 20.1Introduction 20.2 Relational Databases 20.3 Relational Database Overview: Books Database 20.4 SQL 20.4.1Basic SELECT Query 20.4.2 WHERE Clause 20.4.3 ORDER BY Clause 20.4.4Merging Data from Multiple Tables: INNER JOIN 20.4.5 INSERT Statement 20.4.6 UPDATE Statement 20.4.7 DELETE Statement 20.5 ADO.NET Object Model
5
2006 Pearson Education, Inc. All rights reserved. 5 20.6Programming with ADO.NET: Extracting Information from a Database 20.6.1Displaying a Database Table in a DataGridView 20.6.2How Data Binding Works 20.7Querying the Books Database 20.8 Programming with ADO.NET: Address Book Case Study 20.9 Using a DataSet to Read and Write XML 20.10Wrap-Up 20.11Web Resources
6
2006 Pearson Education, Inc. All rights reserved. 6 Fig. 20.23 | Adding a data source to a project. Data Sources windowData menu
7
2006 Pearson Education, Inc. All rights reserved. 7 Fig. 20.24 | Choosing the data source type in the Data Source Configuration Wizard.
8
2006 Pearson Education, Inc. All rights reserved. 8 Fig. 20.25 | Adding a new data connection.
9
2006 Pearson Education, Inc. All rights reserved. 9 Fig. 20.26 | Choosing the Books.mdf data connection.
10
2006 Pearson Education, Inc. All rights reserved. 10 Fig. 20.27 | Saving the connection string to the application configuration file.
11
2006 Pearson Education, Inc. All rights reserved. 11 Fig. 20.28 | Choosing the database objects to include in the DataSet.
12
2006 Pearson Education, Inc. All rights reserved. 12 Fig. 20.29 | Viewing a data source listed in the Data Sources window. Data Sources window
13
2006 Pearson Education, Inc. All rights reserved. 13 Fig. 20.30 | Viewing a database listed in the Solution Explorer.
14
2006 Pearson Education, Inc. All rights reserved. 14 Fig. 20.31 | Design view after dragging the Authors data source node to the Form. authorsBindingNavigator authorsDataGridView Component tray
15
2006 Pearson Education, Inc. All rights reserved. 15 Fig. 20.32 | Displaying the Authors table in a DataGridView. Move to first row Move to next row Move to previous row Move to last row (a) Delete the current row Add a new row Save changes (b) Currently selected row
16
2006 Pearson Education, Inc. All rights reserved. 16 Fig. 20.33 | Data binding architecture used to display the Authors table of the Books database in a GUI.
17
2006 Pearson Education, Inc. All rights reserved. 17 Outline DisplayTable.cs (1 of 2)
18
2006 Pearson Education, Inc. All rights reserved. 18 Outline DisplayTable.cs (2 of 2) (a) (b)
19
2006 Pearson Education, Inc. All rights reserved. 19 Fig. 20.35 | Viewing the BooksDataSet in the Dataset Designer. Dataset Designer TitlesTableAdapter
20
2006 Pearson Education, Inc. All rights reserved. 20 Fig. 20.36 | TableAdapter Query Configuration Wizard to add a query to a TableAdapter.
21
2006 Pearson Education, Inc. All rights reserved. 21 Fig. 20.37 | Choosing the type of query to be generated for the TableAdapter.
22
2006 Pearson Education, Inc. All rights reserved. 22 Fig. 20.38 | Specifying a SELECT statement for the query.
23
2006 Pearson Education, Inc. All rights reserved. 23 Fig. 20.39 | Query Builder after adding a WHERE clause by entering a value in the Filter column. (Part 1 of 2.) (a)
24
2006 Pearson Education, Inc. All rights reserved. 24 Fig. 20.39 | Query Builder after adding a WHERE clause by entering a value in the Filter column. (Part 2 of 2.) (b)
25
2006 Pearson Education, Inc. All rights reserved. 25 Fig. 20.40 | The SELECT statement created by the Query Builder.
26
2006 Pearson Education, Inc. All rights reserved. 26 Fig. 20.41 | Specifying names for the methods to be added to the TitlesTableAdapter.
27
2006 Pearson Education, Inc. All rights reserved. 27 Fig. 20.42 | Dataset Designer after adding Fill and Get methods to the TitlesTableAdapter.
28
2006 Pearson Education, Inc. All rights reserved. 28 Outline DisplayQuery Result.cs (1 of 5)
29
2006 Pearson Education, Inc. All rights reserved. 29 Outline DisplayQuery Result.cs (2 of 5)
30
2006 Pearson Education, Inc. All rights reserved. 30 Outline DisplayQuery Result.cs (3 of 5)
31
2006 Pearson Education, Inc. All rights reserved. 31 Outline DisplayQuery Result.cs (4 of 5) (b) (a)
32
2006 Pearson Education, Inc. All rights reserved. 32 Outline DisplayQuery Result.cs (5 of 5) (c)
33
2006 Pearson Education, Inc. All rights reserved. 33 Outline AddressBook.cs (1 of 3)
34
2006 Pearson Education, Inc. All rights reserved. 34 Outline AddressBook.cs (2 of 3)
35
2006 Pearson Education, Inc. All rights reserved. 35 Outline AddressBook.cs (3 of 3) (b)(a) (c)
36
2006 Pearson Education, Inc. All rights reserved. 36 Fig. 20.45 | Selecting the control(s) to be created when dragging and dropping a data source member onto the Form.
37
2006 Pearson Education, Inc. All rights reserved. 37 Fig. 20.46 | Displaying a table on a Form using a series of Label s and TextBox es.
38
2006 Pearson Education, Inc. All rights reserved. 38 Fig. 20.47 | Dataset Designer for the AddressBookDataSet after adding a query to AddressesTableAdapter.
39
2006 Pearson Education, Inc. All rights reserved. 39 Fig. 20.48 | Design view after adding controls to locate a last name in the address book.
40
2006 Pearson Education, Inc. All rights reserved. 40 Fig. 20.49 | Viewing the DataBindings.Text property of a TextBox in the Properties window.
41
2006 Pearson Education, Inc. All rights reserved. 41 Outline XMLWriter.cs (1 of 3)
42
2006 Pearson Education, Inc. All rights reserved. 42 Outline XMLWriter.cs (2 of 3)
43
2006 Pearson Education, Inc. All rights reserved. 43 Outline XMLWriter.cs (3 of 3)
44
2006 Pearson Education, Inc. All rights reserved. 44 Outline Players.xml
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.