ADO.Net:
There are two main components of ado.net which are .Net framework Data provider and DataSet.
1. .Net frameword Data provider are very lightweight, used to connect with database, run the command/query by using Command object and get the results. then it depends upon us how to treat that Result set either we directly process the data or we place in DataSet as per requirements. there are different types of Data Providers in .Net Framework like:
a. .NET Framework Data Provider for SQL Server
it gives data access for Microsoft SQL Server. Uses namespace System.Data.SqlClient.
b. .NET Framework Data Provider for OLE DB
Used for data sources discovered by using OLE DB. Uses namespace System.Data.OleDb.
c. .NET Framework Data Provider for ODBC
It is used for data sources discovered by using ODBC. Uses namespace System.Data.Odbc.
d. .NET Framework Data Provider for Oracle
It provides supports for Oracle data sources. namespace System.Data.OracleClient
e. EntityClient Provider
give data access to Entity Data Model (EDM) applications. System.Data.EntityClient
f. .NET Framework Data Provider for SQL Server Compact 4.0.
It is for Microsoft SQL Server Compact 4.0. using System.Data.SqlServerCe.
Mainly .Net Framework Data Providers uses few core Objects which are give below:
a. Connection: Used to establish connection. its base class is DbConnection
b. Command: used to execute a database command. this object base class is DbCommand
c. DataReader: it reads a forward-only(DataReader reads one row at a time then move forward to next row then next, it will not move back thats why it's called Forward only), read-only(it will just read records from data source does not allow any editing). base class for DataReader objects is DbDataReader class.
d. DataAdapter: it is used to populates the DataSet. basically it provides communication between data source and DataSet to enable data access and manipulation of data.
There are some additional Objects also names as Transaction, CommandBuilder, ConnectionStringBuilder, Parameter, Exception, Error and ClientPermission.
2. The DataSet: it is second component of ado.net. it is mainly designed to data access from any data source or we can say independent of data source, it can be used with different data source like XML data or to manage data local. DataSet can have one or more than one DataTable objects which have rows, columns even primary and foreign keys contraints. we can perform within application qurieson DataSet to manipulate the data.
Choose DataReader or DataSet:
when you think you want only to read data and there is no requirements to perform editing then DataReader is preferable and fast also but when you require data to cache it locally in application and do some manipulation and perform some other operations then DataSet is best.
No comments:
Post a Comment