Saturday, 3 September 2016

Chapter-1 ADO.Net Entity Framework

ADO.NET is a model used by .NET applications to communicate with a database for retrieving, accessing, and updating data. This module will provide the necessary skills to the students to work as a database application developer in the industry.
.NET Framework enables you to create data centric application that enable you to access data from  various data sources in heterogeneous environment using ADO.NET.

    Brief History

1.    Tebisco is a leading producer and distributor of snacks in the U.S., as well as in most of the company’s 23 international markets. In 1998, consumers spent $9.2 billion on Tebisco’s snacks,  $1.4 billion more than in the previous year.
2.    Tebisco started as a small bakery in Round Rock, Texas in 1978. In a short time, its gingersnaps, macaroons, shortbread and other cookies were popular all over the U.S. Three years ago, the management embarked on a rapid expansion plan. They set up offices in Asia and Europe, in addition to strengthening their U.S. operations.
3.    Tebisco has got a centralized database management system whereby the information about all the HR activities is maintained.

CLICK HERE for ADO.NET Chapter -2 

Overview of ADO.NET

1.    Business applications allow users to retrieve data from a database by presenting data in a user-friendly interface.
2.    ADO.NET enables datacentric application to various data sources and retrieve, manipulate and update data.
3.    ADO.NET use XML to transfer the data across the application and data sources
4.    User need not remember the database commands for retrieving or updating data in the database.
5.    Microsoft has created a family of data access technologies to help programmers build efficient applications to access data, regardless of its source.
6.    The guidelines that can be followed for selecting an appropriate data access technology are:

   a)    Use ADO.NET for writing a managed code targeting the .NET Framework in Visual Basic, C#, and C++.
  b)   Use (OLE) DB for writing a Microsoft based application, a VB 6 COM application, or a C++ application using COM.
  c)    Use JDBC for writing a Java code targeting SQL Server.
  d)   Use Microsoft ODBC for writing a native code targeting Windows by using C or C++.

7.    One of advantage of ADO.NET is it supports disconnected architecture .Using disconnected architecture ,application connect to database server only to retrieve or update the data Hence it reduces the no of open connections.
8.    ADO.NET dataset is a cache of records that you retrieve from data source. Dataset contains from one or more tables. Dataset can also manipulate the data from application without database or by using XML.
9.    .NET data provider enables you to connect to data source and execute commands to retrieve results and manipulate data.

ADO.NET is a part of the .NET Framework architecture.

The ADO.NET Object Model
1.    ADO.NET is based on an object model that is based on the standards laid down by W3C.
2.    The following figure shows the ADO.NET object model.

1.    The two key components of ADO.NET Object model are:

.NET Data provider
1)   .NET Data provider enables an application to connect to a data source, execute commands , retrieve results, Storing the data in a dataset, Reading the retrieved data and Updating the database.

2)   .NET Data provider consist of four key components:
  i)     Connection: Objects enable you to establish and manage  connection to a database.
  ii)    Command : Objects enable you to execute SQL command and retrieve the results from database.
  iii)  DataReader : Objects enable you to read data in sequential manner
  iv)  DataAdapter : Objects enable a database and a dataset to communicate with each other.

3)   System.Data namespace contains two namespaces: System.Data.OleDb and System.Data.SqlClient.

4)   Data provider enable you to perform below tasks:
  a)   Create a connection with a database
  b)   Execute SQL Statement and store procedures on a database
  c)    Read data rows from a database in forward only mode
  d)   Transfer data between a database and Data set
  e)   Display errors and warning message returned by database
  f)    Handle exception when a database return an error
  g)   Execute Transact SQL statements on database

a)   Is a disconnected, cached set of records that are retrieved from a database.
b)   Is present in the Dataset class in the System.Data namespace.
c)    Has the following key components:
  i)     DataTableCollection
  ii)    DataRelationCollection
  iii)  DataTable
  iv)  DataRowCollection
  v)   DataColoumnCollection  

Features of ADO.NET
1)   The key features of ADO.NET are:
  a)   Disconnected data architecture 
2)   Applications connect to the database only while retrieving and updating data.
3)   Connection with the database is closed, once the data is retrieved.
4)   Connection is   re-established when the data needs to be updated.
  a)   Data cached in datasets
5)   The data is retrieved and stored in datasets.
6)   You can work with the records stored in a dataset as you work with real data.
7)   The dataset is independent of data source and you remain disconnected from the data source.

Benefits of ADO.NET
ADO.NET has many benefites:

Interoperability :
ADO.NET use XML to exchange data, any component that understand XML can receive data from ADO.NET .

Maintainability :
Application created using ADO.NET are easier to manage and scale than application created in ADO.ADO.NET enables you to easily increase tiers in a deployed application because ADO.NET use XML to transfer data between tires .

ADO.NET simplifiers programming for various tasks such as execution SQL commands. This enable you to increase productivity and minimize the number of errors

ADO disconnected record set use COM marshaling to transfer data between application . This requires data type conversion in order for COM to recognize data types and conversion diminished the performance of an application. ADO.NET use XML to transfer the data then no conversion required.

1. Database operations are performed on the dataset instead of on the database.
2. As a result, resources are saved and the database can meet the increasing demands of users more efficiently.
3. With the increase in data and the changes in business model of organization the demand for data has increased rapidly.
4. It enables you to reduce the open connections to the database and results in optimum usage of resources.

Data transfer in XML format
1. XML is the fundamental format for data transfer in ADO.NET.
2. Because a dataset is stored in the XML format, you can transmit it between different types of applications.
a)   ADO.NET is a data access programming model for accessing the data stored in a database from a .NET application.
b)   The ADO.NET object model consists of two main components, data provider and dataset.
c)    A data provider is used for connecting to a database, retrieving data, storing the data in a
dataset, reading the retrieved data, and updating the database.
d)   The various types of data providers are:
   i)     .NET Framework data provider for SQL Server
  ii)    .NET Framework data provider for OLEDB
  iii)  .NET Framework data provider for ODBC
  iv)  .NET Framework data provider for Oracle
e)   The four key components of a data provider are:
  i)     Connection
  ii)    Commnd
  iii)  DataReader
  iv)  DataAdapter
       f)    The dataset is memory-based relational representation of data. 

       g)   The main features of ADO.NET are:
  i)     Disconnected data architecture
  ii)    Data cached in datasets
  iii)  Scalability
  iv)  Data transfer in XML format

I hope that the functionality of the above attribute is clear to you now. Now you can use this code in your application. If you have further question, just drop a line below and I will try to answer you as soon as possible.

Last but not least, connect with me on Twitter , Facebook , LinkedIn and Google+ for technical updates and articles news. We won’t spam or share your email address as we respect your privacy.

No comments:

Post a Comment