Logo F2FInterview

ADO .NET Interview Questions

Q   |   QA

In order to interact with any database we need a Connection . This connection enables us to know the Server Name, User-Id,Password,Database Name. These are the main requirements to connect to a Database.
So in our Connection string we provide all those above mentioned properties as parameters.
Different Connection objects : SqlConnection, OleDbConnection, OdbcConnection
. OleDbConnection object is used with an OLE-Db Provider

OleDbConnection cnn ;
connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=DatabaseName;";
cnn = new OleDbConnection(connetionString);

. SqlConnection object used the Tabular Data Services (TDS) With MS Sql Server.

SqlConnection con;
con = new SqlConnection("server=SERVER NAME;user id=ID;password=PASSWORD;database=DB NAME");
SqlCommand cmd;
cmd = new SqlCommand("DB Query Here",con);

. Using the OdbcConnection , we will create an OdbcCommand. From that command we can issue a Query and create an OdbcDataReader.

OdbcConnection DbConnection = new OdbcConnection("Connection String");
OdbcCommand DbCommand = DbConnection.CreateCommand();
DbCommand.CommandText = "Db Query Here";
OdbcDataReader DbReader = DbCommand.ExecuteReader();

Data view is used to sort and find data in a data table.

These objects connect one or more Command objects to a Dataset object. They provide logic that would get data from the data store and populates the tables in the Dataset, or pushes the changes in the Dataset back into the data store.

  • An OleDbDataAdapter object is used with an OLE-DB provider
  • A SqlDataAdapter object uses Tabular Data Services with MS SQL Server.

Data reader and Dataset are the two fundamental objects in ADO.NET.

BENEFITS OF ADO.NET
Scalability
ADO.NET works on DataSet that can represent a whole database or even a data table as a disconnected object and thereby eliminates the problem of the constraints of number of databases being connected. In this way scalability is achieved.


Data Source Independence
In ADO.NET DataSet is completely independent of data source and no way DataSet is controlled by the data source as it happens in case of RecordSet.

Interoperability
As ADO.NET transmits the data using the format of XML which is not dependent on ADO.NET or windows platform.

Strongly Typed Fields
It supports strongly typed fields by using CTS.

Performance
The performance in ADO.NET is higher in comparison to ADO that uses COM marshalling.

Firewall
As in ADO.NET transmission is via XML format, therefore it can pass through firewalls.

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: