ADO.NET Questions and Answers
|ADO.Net is commonly termed as ActiveX Data Objects which is a part of .Net Framework. ADO.Net framework has set of classes which are used to handle data access by connecting with different databases like SQL, Access, Oracle, etc…|
Following namespaces are used to connect to Database.
The System.Data namespace.
The System.Data.OleDb namespace – A data provider used to access database such as Access, Oracle, or SQL.The System.Data.SQLClient namespace – Used to access SQL as the data provider.
There are two important objects of ADO.Net:
DataReader and .DataSet.
Following are the components of ADO.Net Data provider:
Connection object – Represents connection to the Database
Command object – Used to execute stored procedure and command on Database
ExecuteNonQuery – Executes command but doesn’t return any value
ExecuteScalar – Executes and returns single value
ExecuteReader – Executes and returns result set
DataReader – Forward and read only recordsetDataAdapter – This acts as a bridge between database and a dataset.
Following are the benefits of ADO.Net:
|The DataAdapter class uses Rowstates to extract modified, added, or deleted records.|
|The Execute Non Query method executes SQL commands that don't return a result set.|
Below Data Providers are used in ADO.NET framework.
.NET Framework Data Provider for SQL Server – A Data provider that provides access to Microsoft SQL Server 7.0 or later version and it uses the System.Data.SqlClient namespace.
.NET Framework Data Provider for OLE DB – A Data Provider that provides access to any database exposed by using OLE DB and it uses the System.Data.OleDb namespace.
.NET Framework Data Provider for ODBC – A Data Provider that provides access to any databases exposed by using ODBC and It uses the System.Data.Odbc namespace. .NET Framework Data Provider for Oracle – A Data Provider that provides access to Oracle database 8.1.7 or later versions and it uses the System.Data.OracleClient namespace.
|Typed datasets use explicit names and data types for their members but untyped dataset uses table and columns for their members.|
|ADO.Net Connection object is used to establish a connection between application and the data source. SQL Commands can be executed once this connection has been established. It is mandatory to close the connection object once data base activities are completed.|