Presentation is loading. Please wait.

Presentation is loading. Please wait.

Objectives In this lesson, you will learn to: *Identify the need for ADO.NET *Identify the features of ADO.NET *Identify the components of the ADO.NET.

Similar presentations


Presentation on theme: "Objectives In this lesson, you will learn to: *Identify the need for ADO.NET *Identify the features of ADO.NET *Identify the components of the ADO.NET."— Presentation transcript:

1 Objectives In this lesson, you will learn to: *Identify the need for ADO.NET *Identify the features of ADO.NET *Identify the components of the ADO.NET object model *Connect to a database by creating a data adapter *Access a database through a dataset * Preview the data adapter result

2 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 ADO.NET *Is a model used by Visual Basic.NET applications to communicate with a database for retrieving, accessing, and updating data. * Uses a structured process flow to interact with a database.

3 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 Features of ADO.NET *Disconnected data architecture — Applications connect to the database only while retrieving and updating data. *Data cached in datasets — ADO.NET is based on a disconnected data structure. Therefore, the data is retrieved and stored in datasets. *Data transfer in XML format — ADO.NET uses XML for transferring information from a database into a dataset and from the dataset to another component. * Interaction with the database is done through data commands.

4 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 ADO.NET Object Model Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 ADO.NET Object Model DATASET VISUAL BASIC.NET APPLICATION (WINDOWS/ WEB FORM) DATA PROVIDER Accessing retrieved data CONNECTION COMMAND DATA ADAPTER DATA READER Establishes connection with the database Filling dataset with data Transfers data to the dataset and reflects the changes made in the dataset to the database DATABASE Retrieves data in a read-only, forward only mode Executes a command to retrieve data from the database

5 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 ADO.NET Object Model (Contd.) *Data from a database can be assessed through: 3A dataset  A DataReader object *

6 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 Key Components of the ADO.NET Model *Data Provider 3Is used for connecting to a database, retrieving data, and storing the data. 3Is of two types: OLE DB data provider SQL Server data provider

7 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 Components of a Data Provider *Connection 3Used to establish a connection with a data source 3Some commonly used properties and methods: ConnectionString property Open() method Close() method State property

8 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 Components of a Data Provider (Contd.) *Data adapter 3Creates a dataset and updates the database. 3Handles data transfer between the database and the dataset through its properties and methods. 3Displays the data through the process of table mapping. 3Are of two types: SqlDataAdapter OleDbDataAdapter 3 *

9 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 Components of a Data Provider (Contd.) *Data command 3Is a SQL statement or a stored procedure that is used to retrieve, insert, delete, or modify data from a data source.  Is an object of the OleDbCommand or SQLCommand class.

10 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 Components of a Data Provider (Contd.) *Data reader 3Is used to retrieve data from a data source in a read-only and forward-only mode. 3Stores a single row at a time in the memory. 3Commonly used methods: Read() Close() NextResult()  *

11 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 Dataset *Is a disconnected, cached set of records that are retrieved from a database.  Is present as a DataSet class in the System.Data namespace. * Has its own object model.

12 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 Dataset Object Model DataRowDataColumn DATASET DataRelationCollection DataRelation DataTableCollection DataTable DataRowCollectionDataColumnCollection ExtendedProperties DataViewPrimaryKey

13 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 Problem Statement 5.D.1 The call center application needs to provide the facility of viewing the customer details for the Sales department.

14 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 Task List *Identify the data that needs to be displayed. *Identify the method for creating a data adapter. *Identify the type of dataset to be created. *Create a data adapter. *Create a dataset. *Preview the database records.

15 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 Task 1: Identify the data that needs to be displayed. Result: *As per the given problem statement, the data to be displayed is as follows: 3CustID 3FName 3LName 3Address 3Phone 3 email

16 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 Task 2: Identify the method for creating a data adapter. *There are three methods to create a data adapter: 3Manually 3Through a wizard 3Using the Server Explorer window Result: * In the given problem statement, you will create a data adapter by using Data Adapter Configuration Wizard since it lets you create a data adapter with minimum steps.

17 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 Task 3: Identify the type of dataset to be created. *Datasets are of two types: 3Typed 3Untyped *Typed dataset  Is derived from the DataSet class and has an associated XML schema, which is created at the time of the creation of the dataset. 3Can be customized after creation. 3 Supports Intellisense and auto ‑ completion for the elements of the syntax while writing code.

18 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 Task 3: Identify the type of dataset to be created. (Contd.) *Untyped dataset 3Does not have any associated XML schema, therefore, the structure of an untyped dataset is not known at the compile time. 3Represents tables and columns as collections. 3Does not support Intellisense and auto ‑ completion for the elements of the syntax. Result: * Since the structure of the data is known at compile time, you will create a typed dataset for the given problem statement.

19 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 Task 4: Create a data adapter. Task 5: Create a dataset. Task 6: Preview the database records.

20 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 Problem Statement 5.P.1 An application needs to be created that allows the Diaz Telecommunications Sales Manager to preview the customer order details from the database. In addition, for each order, percentage of the cost of a product given as advance needs to be previewed.

21 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 Summary In this lesson, you learned that: *ADO.NET is a data access programming model for accessing the data stored in a database from a.NET application. *ADO.NET has the following features: 3A disconnected data architecture 3Data cached in datasets 3The use of XML format for data transfer 3 Database operations done through data commands

22 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 Summary (Contd.) *ADO.NET consists of the following components: 3Data Provider — Used for connecting to a database, retrieving data, storing the data in a dataset, and updating the database. 3Data Adapter — A data adapter is integral to the working of the ADO.NET model since data transfer to and from the database is done through a data adapter. 3Dataset — A dataset is a disconnected cached set of records that are retrieved from the database. * A data adapter communicates with a database through data commands. These data commands use parameters for execution.

23 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 Summary (Contd.) *After a dataset has been created, a data adapter uses the process of table mapping to map the columns in the database table with the dataset columns. *A data adapter can be created by using any of the following methods: 3Manually 3Through a wizard 3 By using Server Explorer

24 Working with ADO.NET Working with ADO.NET/Lesson 5/Slide ‹#› of 30 Summary (Contd.) *Datasets are of two types: 3Typed datasets – A typed dataset is derived from the DataSet class and has an associated schema. 3Untyped datasets – An untyped dataset does not have any associated XML schema. The tables and columns in an untyped dataset are represented as collections. *


Download ppt "Objectives In this lesson, you will learn to: *Identify the need for ADO.NET *Identify the features of ADO.NET *Identify the components of the ADO.NET."

Similar presentations


Ads by Google