ADO.NET is a data access technology in the .NET Framework that provides a set of classes for interacting with data sources, such as databases, in a disconnected manner.
The primary components are Connection
, Command
, DataReader
, DataAdapter
, and DataSet
.
Connection
object in ADO.NET?The Connection
object is used to establish and manage a connection to a data source, such as SQL Server or Oracle.
Command
object in ADO.NETThe Command
object is used to execute SQL queries and commands against a data source, including SELECT
, INSERT
, UPDATE
, and DELETE
operations
DataReader
is a forward-only, read-only cursor used to efficiently retrieve data from a data source in a fast and lightweight manner
Explain the difference between DataSet
and DataTable
in ADO.NET.
Answer: DataSet
is an in-memory representation of data that can contain multiple DataTable
objects, while DataTable
represents a single table of in-memory data.
DataAdapter
class in ADO.NET?Answer: The DataAdapter
class acts as a bridge between a DataSet
and a data source, facilitating the retrieval and updating of data.
Answer: Connection pooling is a technique used to manage database connections efficiently by reusing active connections instead of creating new ones for each request, improving performance
Answer: ADO.NET handles transactions using the SqlTransaction
class, allowing multiple operations to be executed as a single unit of work, with methods like BeginTransaction
, Commit
, and Rollback
.
The advantages include efficient data management, support for disconnected data architecture, strong type safety, integration with XML, and robust transaction management.