Monday, April 25, 2016

ADO.Net


 What is Ado.Net in brief

  • ADO.Net stands for Activex Data object and it contains set of libraries which allows us to interact with database and XML.
  • It also contains number of classes which allows our application to communicate with data source.
What is difference between ADO.Net and Classic ADO

ADO.Net
Classic ADO
It is a Disconnected Architecture. It is a Connected Architecture
It is provided by Data set and Data Adapter It is provided by Record set
Even though if an Application is disconnected with the database.we can retrieve and access data. Application need to be connected to the database always while working on a data

What are two fundamental objects in ADO.Net
  • Data set and Data Reader are two fundamental objects in ADO.Net
What is Object Pooling
  • Object Pooling is used to store Pool(groups) of object with in the memory which can be reused later.
  • When a new object is required to create then instead of creating a new object,Object in the pool can be allocated there by minimizing the creation of new objects.
What are DataAdapter.Update and dataset.Acceptchanges Method
  • Dataset.Acceptchanges will only changes the rows present in dataset but DataAdapter.Update method will perform DML Operations like Isert,Update or Delete and also reflects the changes made in dataset to database.
What are the Namespaces used in ADO.net to connect to a database
  • Namespaces which are used to connect to database are listed below
  • System.data Namespace
  • System.data.SQLClient-Which is used to connect to SQL database
  • System.data,OleDB-Which helps us to connect to Access,Oracle or SQL database.
What is the role of Dataset object in ADO.Net
  • Dataset allows us to store the data retrieved from database by dataAdapter and make it available for all .Net Applications.
  • In order to fill the data into dataset,Fill method in the dataAdapter is used.
  • When Fill method is called DataAdapter will opens a connection to database,Executes the select command,retrieves the data and fills it into dataset and closes the connection automatically.
  • As connection to the database is closed any changes made in dataset will not send directly  to database.
  • In order to send the changes made in dataset to database an Update method of Dataadapter is called which will again opens the connection to database,Performs the DML Operations like Insert,Update and Delete which will reflect the database and immediately closes the connection.
  • As connection to the database is Opened when required and will immediately closes the Connection when not required.This Architecture is called as Disconnected Architecture.
What is DataReader object in ADO.Net
  • DataReader is used to store the data retrieved by the command object Execute Reader and make it available for all .Net Applications.
  • DataReader is a connected Architecture and data with in the datareader is a Read Only mode and with in the datareader we can navigate only in forward direction.
  • To Access one by one record from the datareader we make use of Read method which is in datareader object.
What is the use of Connection Object
  • Connection Object helps us to Communicate with datasource and an Application.
  • Depending upon the parameters specified in the Connection string ADO.Net connects to the specific database,Opens a connection to database.
  • When the connection to database is established,SQL Commands will gets executed and fetches the data from database.
What is the use of CommandBuilder Class
  • CommandBuilder is used to automatically update a database according to the changes made in dataset
  • Whenever a data inside a row changes then Command Builder object will automatically generates a SQL Statements and commit the changes made in dataset to database.
What is the use of SQLCommand object
  • SQLCommand object allow users to interact with database and performs an DML Operation like Insert,Update,Delete and Select for retrieving and manipulating data.
What are the components of ADO.Net provider
  • It mainly consists of Connection,Command,Data Reader and Dataadapter objects.
  • Connection Object: It allows us to connect to the database based on the parameters specified in the Connection string.
  • Command Object:  Once after the connectivity to the database is established then SQL Commands will get executed for retrieving and Manipulating data.
  • Data Reader: It allows us to retrieve data from database with the help of Execute Reader.
  • Data Adapter:It acts a a Mediator which allows us to communicate between database and an Application.It retrieves the data from database and stores the data in dataset and also reflects the changes made in dataset to database.
What is Execute Reader,Execute Nonquery and Execute Scalar in ADO.Net
  • Execute Nonquery: It executes a SQL Statements with in the database and returns the Number of rows affected.
  • Execute Scalar: It returns a First column single value from the entire result set.
  • Execute Reader:It returns a result set by using DataReader object.
What is Connection Pooling in ADO.Net
  • Connection Pooling helps us to group the database connection in a cache which can be reused later.Every time opening a new connection to database is a time consuming process.
  • Therefore Connection pooling helps us to reuse the already existing and active connection which increases the performance of an Application.
  • To enable or disable Connection pooling set pooling property to true or false in Connection string.
Explain ADO.Net Dataadapter in brief
  • DataAdapter acts as a mediator which helps us to communicate between datasource and an Application.
  • DataAdapter retrieves the data from database and stores it in dataset and also reflects the changes that are made in dataset to database.
  • DataAdapter make use of Fill method to fill the data in dataset and to reflect the changes made in dataset to database Update method of DataAdapter is used.
What is difference between DataReader and Dataset

Dataset
DataReader
It acts as a disconnected Architecture It acts as a connected Architecture
With in dataset we can navigate forward and backward With in DataReader we can navigate in Forward direction
We can make changes in dataset We cannot make changes in dataReader as it is a Read only Mode.
Dataset is slower when compared with dataReader because it contains Constraints,Relationships among the table DataReader is faster when compared with dataset.


Which property is used to check whether dataReader is opened or Closed
  • DataReader consists of Isclosed property which is used to check whether it is opened or closed.
  • It returns true if datareader is closed or else it returns false.
Is it possible to edit  data in Repeater control
  • No it is not possible to edit the data in Repeater control.
What is difference between Dataset.clone and Dataset.copy
  • Dataset.clone copies the structure of dataset including constraints,schemas and relations where as Dataset.copy copies both structure and data from the table.
Which keyword is used to accept variable number of parameters
  • Params keyword is used to accept variable number of parameters.
What are the classes that are available in System.Data namespace
  • Classes which are available in System.Data are listed below
  • Dataset,DataTable,,DataColumn,DataRow,DataRelation and constraint
What are the classes available in System.Data.Common Namespace
  • DataColumnMapping and DataRowMapping are the two classes available in System.Data.Common Namespace

No comments:

Post a Comment