Introduction to ADO.NET


Introduction

ADO: ActiveX Data Object
Provides access to the data sources like MS Access, SQL, Oracle, XML...
Root classes are found in the System.Data
XML integration is provided by System.Xml

Architecture

Connected Architecture
Disconnected Architecture: Read all data at a time and store it in the data set




To access databases such as SQL, Oracle, and MS Access in .NET Framework we have classes that behave as Data Providers in the System.Data namespace.

Classes such as:
Connection, Command (Insert, Update, Delete): Connected Architecture
Retrieving the data - DataReader: Connected Architecture
                                  Data Adapter: Disconnected Architecture

DataReader: Useful when we have a small amount of records to be retrieved from the DB. Whenever the SELECT statement is executed it will generate a result set in DB, and DataReader will every time go to the DB and read one data at a time. Round trip increase.

Data Adapter: Put all the data from a particular connection and fill a dataset (disconnected architecture). And continue accessing the data from time to time.


Here Data Providers are:
System.Data.SqlClient
System.Data.OracleClient
System.DataOleDb (Object Linking and Embedding): MS Access-like thing
System.Data.Odbc (Open Database Connectivity)

Each Data Providers will provide different classes like:
Connection,
Commands,
DataReader,
DataAdapter

Finally, a DataSet which keeps the data in Disconnected mode.

Disconnected Architecture:

It's a storage & management of data without connection
Data is stored in the client's machine
System.Data provides the required classes
DataTable, DataColumn, DataRow ... are a few common classes
Data is stored in tabular format only


DataSet:

It's a collection of data tables
DataAdapter gets the data from DB and fills the dataset
Relationships can be maintained
Can sync the database


Connected Architecture:

The connection class establishes the DB connection
Command class executes the commands (DML, DQL)
DataReader reads data one by one from the DB in a forward-only manner
DataAdaptor behaves as a bridge between connected and disconnected architecture






Executing Commands:













Popular posts from this blog

Introduction to Docker

SOLID Principles

Nuget package | Pushing it to Azure Artifacts

WiX - Windows Installer XML

Working with Git

C# Memory Tricks: Learn How To Master The Garbage Collector

gRPC - Protobuf / Protocol Buffers

Custom Azure DevOps pipeline task extension

C# Questions Part 1