1 / 52

Objectives

1. Objectives. Define the terms used when talking about databases Explain the purpose of the DataAdapter, Connection, and DataSet objects Explain the role of the provider Create and configure an OleDbDataAdapter object Write SQL SELECT statements. Objectives ( continued ). Create a dataset

boaz
Télécharger la présentation

Objectives

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 1

  2. Objectives • Define the terms used when talking about databases • Explain the purpose of the DataAdapter, Connection, and DataSet objects • Explain the role of the provider • Create and configure an OleDbDataAdapter object • Write SQL SELECT statements Microsoft Visual Basic .NET: Reloaded

  3. Objectives (continued) • Create a dataset • Display a dataset in various controls in an interface • Position the record pointer in a dataset Microsoft Visual Basic .NET: Reloaded

  4. Database Terminology • Database • Organized collection of related information stored in a file on a disk • Relational database stores information in tables composed of columns and rows • Table is a group of related records • Each row represents a record • Each column represents a row • Primary key is a field that uniquely identities a record in a table • Foreign key is a field in one table used as the primary key in another table • Tables are related by a common field or fields Microsoft Visual Basic .NET: Reloaded

  5. Database Terminology (continued) Microsoft Visual Basic .NET: Reloaded

  6. Database Terminology (continued) Microsoft Visual Basic .NET: Reloaded

  7. ADO.NET • A Connection object is used to establish a temporary connection to a database • Requests for information are then submitted using a DataAdapter object • The DataAdapter uses a provider which translates the request into a language the database understands • A DataSet stores a copy of the records and fields requested in a internal memory location Microsoft Visual Basic .NET: Reloaded

  8. ADO.NET (continued) Microsoft Visual Basic .NET: Reloaded

  9. ADO.NET (continued) Microsoft Visual Basic .NET: Reloaded

  10. Creating and Configuring a DataAdapter Object Microsoft Visual Basic .NET: Reloaded

  11. Creating and Configuring a DataAdapter Object (continued) Microsoft Visual Basic .NET: Reloaded

  12. Creating and Configuring a DataAdapter Object (continued) Microsoft Visual Basic .NET: Reloaded

  13. Creating and Configuring a DataAdapter Object (continued) Microsoft Visual Basic .NET: Reloaded

  14. Creating and Configuring a DataAdapter Object (continued) Microsoft Visual Basic .NET: Reloaded

  15. Creating and Configuring a DataAdapter Object (continued) Microsoft Visual Basic .NET: Reloaded

  16. SQL • Structured Query Language (SQL) • A set of commands that allows you to access and manipulate the data stored in many database management systems on computers of all sizes • SELECT statement allow you to specify which fields and records you want to view • WHERE clause limits records to be selected • ORDER BY clause sorts record display order Microsoft Visual Basic .NET: Reloaded

  17. HOW TO… Microsoft Visual Basic .NET: Reloaded

  18. HOW TO… (continued) Microsoft Visual Basic .NET: Reloaded

  19. Using the Query Builder to Enter a SELECT Statement Microsoft Visual Basic .NET: Reloaded

  20. Using the Query Builder to Enter a SELECT Statement(continued) Microsoft Visual Basic .NET: Reloaded

  21. Using the Query Builder to Enter a SELECT Statement(continued) Microsoft Visual Basic .NET: Reloaded

  22. Using the Query Builder to Enter a SELECT Statement (continued) Microsoft Visual Basic .NET: Reloaded

  23. Using the Query Builder to Enter a SELECT Statement (continued) Microsoft Visual Basic .NET: Reloaded

  24. Using the Query Builder to Enter a SELECT Statement (continued) Microsoft Visual Basic .NET: Reloaded

  25. Using the Query Builder to Enter a SELECT Statement (continued) Microsoft Visual Basic .NET: Reloaded

  26. Creating a DataSet Microsoft Visual Basic .NET: Reloaded

  27. Creating a DataSet (continued) Microsoft Visual Basic .NET: Reloaded

  28. Creating a DataSet (continued) • XML (Extensible Markup Language) • XML schema definition file defines the tables and fields that make up the data set • Schema file is automatically generated by VB.NET • Contents of file may be viewed in IDE • Contents of dataset can be preview by right clicking the DataAdapter object in the component tray and clicking Preview Data Microsoft Visual Basic .NET: Reloaded

  29. Creating a DataSet (continued) Microsoft Visual Basic .NET: Reloaded

  30. Using the Fill Method • Method of the DataAdapter object • Fills a dataset with data while the application is running Microsoft Visual Basic .NET: Reloaded

  31. Binding the Dataset Object to a DataGrid Control • Connecting a DataSet object to a control is called “binding” • Connected controls are referred to as “bound controls” Microsoft Visual Basic .NET: Reloaded

  32. HOW TO… Microsoft Visual Basic .NET: Reloaded

  33. Binding the Dataset Object to a DataGrid Control (continued) Microsoft Visual Basic .NET: Reloaded

  34. Reconfiguring the DataAdapter Object Microsoft Visual Basic .NET: Reloaded

  35. Reconfiguring the DataAdapter Object (continued) Microsoft Visual Basic .NET: Reloaded

  36. Reconfiguring the DataAdapter Object (continued) Microsoft Visual Basic .NET: Reloaded

  37. Binding the Dataset Object to a Label Control or Text box Microsoft Visual Basic .NET: Reloaded

  38. Binding the Dataset Object to a Label Control or Text box (continued) Microsoft Visual Basic .NET: Reloaded

  39. Binding the Dataset Object to a Label Control or Text box (continued) Microsoft Visual Basic .NET: Reloaded

  40. Binding the Dataset Object to a Label Control or Text box (continued) Microsoft Visual Basic .NET: Reloaded

  41. Programming Example – Cartwright Industries Application • Carl Simons, the sales manager at Cartwright Industries, records the item number, name, and price of each product the company sells in a database named Items.mdb • The database is contained in the VbDotNet\Chap12\Databases folder. • Mr. Simons wants an application that the sales clerks can use to enter an item number and then display the item’s price Microsoft Visual Basic .NET: Reloaded

  42. Programming Example – Cartwright Industries Application (continued) • Items.mdb database opened in Microsoft Access. Database contains one table tblItems Microsoft Visual Basic .NET: Reloaded

  43. TOE Chart Microsoft Visual Basic .NET: Reloaded

  44. User Interface Microsoft Visual Basic .NET: Reloaded

  45. Objects, Properties, and Settings Microsoft Visual Basic .NET: Reloaded

  46. Tab Order Microsoft Visual Basic .NET: Reloaded

  47. Pseudocode btnExit Click event procedure 1. close application frmCartwright Load event procedure 1. fill the dataset with the item numbers and prices from the Items.mdb database Microsoft Visual Basic .NET: Reloaded

  48. Code Microsoft Visual Basic .NET: Reloaded

  49. Summary • Databases created by Microsoft Access are relational databases: • Can contain one or more tables • Most tables contain a primary key that uniquely identifies each record • Data in relational database can be displayed in any order, and you can control the amount of information you want to view • Visual Basic .NET uses a technology called ADO.NET to access the data stored in a database Microsoft Visual Basic .NET: Reloaded

  50. Summary (continued) • Connection between a database and an application that uses ADO.NET is only temporary • To access data stored in a database, first create and configure a DataAdapter object, which is the link between the application and the Connection object • Use an OleDbDataAdapter object and an OleDbConnection object in applications that access Microsoft Access databases Microsoft Visual Basic .NET: Reloaded

More Related