What is ADO.Net?
Most of the today’s applications need to interact with database systems to persist, edit or view data. In .Net data access service is provided through ADO.Net (ActiveX Data Object in Dot Net) components. ADO.Net is an object oriented framework that allows you to interact with database systems. We usually interact with database systems through SQL queries or stored procedures. ADO.Net encapsulates our queries and commands to provide a uniform access to various database management systems.
ADO.Net is a successor of ADO (ActiveX Data Object). The prime features of ADO.Net are its disconnected data access architecture and XML integration.
What does it mean by disconnected data access architecture of ADO.Net?
ADO.Net introduces the concept of disconnected data architecture. In traditional data access components, you make a connection to the database system and then interact with it through SQL queries using the connection.
The application stays connected to the DB system even when it is not using DB services. This commonly wastes the valuable and expensive database resource as most of the time applications only query and view the persistent data. ADO.Net solves this problem by managing a local buffer of persistent data called data set.
Your application automatically connects to the database server when it needs to pass some query and then disconnects immediately after getting the result back and storing it in dataset. This design of ADO.Net is called disconnected data architecture and is very much similar to the connection less services of http over the internet. It should be noted that ADO.Net also provides the connection oriented traditional data access services.
Another important aspect of the disconnected architecture is that it maintains the local repository of data in the dataset object. The dataset object stores the tables, their relationship and different constraints.
The user performs operations like update, insert, delete to this dataset locally and finally the changed dataset is stored in actual database as a batch when needed. This greatly reduces the network traffic and results in the better performance.
What does it mean by connected data access architecture of ADO.Net?
In the connected environment, it is your responsibility to open and close the database connection. You first establish the database connection, perform the interested operations to the database and when you are done, close the database connection. All the changes are done directly to the database and no local (memory) buffer is maintained.
What's the difference between accessing data with dataset or data reader?
The dataset is generally used when you like to employ the disconnected architecture of the ADO.Net. It reads the data into the local memory buffer and perform the data operations (update, insert, delete) locally to this buffer.
The data reader, on the other hand, is directly connected to the database management system. It passes all the queries to the database management system, which executes them and returns the result back to the application.
Since no memory buffer is maintained by the data reader, it takes up fewer resources and performs more efficiently with small number of data operations. The dataset, on the other hand is more efficient when large number of updates are to be made to the database. All the updates are done in the local memory and are updated to the database in a batch. Since database connection remains open for the short time, the database management system does not get flooded with the incoming requests.
What are the performance considerations when using dataset?
Since no memory buffer is maintained by the data reader, it takes up fewer resources and performs more efficiently with small number of data operations. The dataset, on the other hand is more efficient when large number of updates are to be made to the database. All the updates are done in the local memory and are updated to the database in a batch.
Since database connection remains open for the short time, the database management system does not get flooded with the incoming requests.
However, since the dataset stores the records in the local buffer in the hierarchical form, it does take up more resources and may affect the overall performance of the application.
How to select dataset or data reader?
The data reader is more useful when you need to work with large number of tables, database in non-uniform pattern and you need not execute the large no. of queries on few particular table.
When you need to work on fewer no. of tables and most of the time you need to execute queries on these fewer tables, you should go for the dataset.
It also depends on the nature of application.
If multiple users are using the database and the database needs to be updated every time, you must not use the dataset. For this, .Net provides the connection oriented architecture. But in the scenarios where instant update of database is not required, dataset provides optimal performance by making the changes locally and connecting to database later to update a whole batch of data. This also reduces the network bandwidth if the database is accessed through network.
Disconnected data access is suited most to read only services. On the down side, disconnected data access architecture is not designed to be used in the networked environment where multiple users are updating data simultaneously and each of them needs to be aware of current state of database at any time (e.g., Airline Reservation System).
How XML is supported in ADO.Net?
The dataset is represented in the memory as an XML document. You can fill the dataset by XML and can also get the result in the form of XML. Since XML is an international and widely accepted standard, you can read the data using the ADO.Net in the XML form and pass it to other applications using Web Service.
These data consuming application need not be the essentially Dot Net based. They may be written with Java, C++ or any other programming language and running on any platform.
ADO.Net also contains some database specific classes. This means that different database system providers may provide classes (or drivers) optimized for their particular database system. The provider for such classes are called the Dot Net Framework Data Providers. Microsoft itself has provided the specialized and optimized classes for their SQL server database system. The name of these classes start with ‘Sql’ and these are contained in System.Data.SqlClient namespace.
Similarly, Oracle has also provided its classes (driver) optimized for Oracle DB System. Microsoft has also provided the general classes which can connect your application to any OLE supported database server. The name of these classes start with ‘OleDb’ and these are contained in System.Data.OleDb namespace. In fact, you can use OleDb classes to connect to SQL server or Oracle database but using the database specific classes generally provides optimized performance.
RELATED POST
ASP.NET INTERVIEW QUESTIONS AND ANSWERS PART ONE
ASP.NET INTERVIEW QUESTIONS AND ANSWERS PART TWO
ASP.NET INTERVIEW QUESTIONS AND ANSWERS PART THREE
ASP.NET INTERVIEW QUESTIONS AND ANSWERS PART FOUR
ASP.NET INTERVIEW QUESTIONS AND ANSWERS PART FIVE
ADO.NET INTERVIEW QUESTIONS AND ANSWERS PART ONE
ADO.NET INTERVIEW QUESTIONS AND ANSWERS PART TWO
You can also learn the concept of frame work concept in detail with questions and answers in the following place.
MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART ONE
MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART TWO
MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART THREE
MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART FOUR
MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART FIVE
MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART SIX
MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART SEVEN
MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART EIGHT
MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART NINE
MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART TEN
Most of the today’s applications need to interact with database systems to persist, edit or view data. In .Net data access service is provided through ADO.Net (ActiveX Data Object in Dot Net) components. ADO.Net is an object oriented framework that allows you to interact with database systems. We usually interact with database systems through SQL queries or stored procedures. ADO.Net encapsulates our queries and commands to provide a uniform access to various database management systems.
ADO.Net is a successor of ADO (ActiveX Data Object). The prime features of ADO.Net are its disconnected data access architecture and XML integration.
What does it mean by disconnected data access architecture of ADO.Net?
ADO.Net introduces the concept of disconnected data architecture. In traditional data access components, you make a connection to the database system and then interact with it through SQL queries using the connection.
The application stays connected to the DB system even when it is not using DB services. This commonly wastes the valuable and expensive database resource as most of the time applications only query and view the persistent data. ADO.Net solves this problem by managing a local buffer of persistent data called data set.
Your application automatically connects to the database server when it needs to pass some query and then disconnects immediately after getting the result back and storing it in dataset. This design of ADO.Net is called disconnected data architecture and is very much similar to the connection less services of http over the internet. It should be noted that ADO.Net also provides the connection oriented traditional data access services.
Another important aspect of the disconnected architecture is that it maintains the local repository of data in the dataset object. The dataset object stores the tables, their relationship and different constraints.
The user performs operations like update, insert, delete to this dataset locally and finally the changed dataset is stored in actual database as a batch when needed. This greatly reduces the network traffic and results in the better performance.
What does it mean by connected data access architecture of ADO.Net?
In the connected environment, it is your responsibility to open and close the database connection. You first establish the database connection, perform the interested operations to the database and when you are done, close the database connection. All the changes are done directly to the database and no local (memory) buffer is maintained.
What's the difference between accessing data with dataset or data reader?
The dataset is generally used when you like to employ the disconnected architecture of the ADO.Net. It reads the data into the local memory buffer and perform the data operations (update, insert, delete) locally to this buffer.
The data reader, on the other hand, is directly connected to the database management system. It passes all the queries to the database management system, which executes them and returns the result back to the application.
Since no memory buffer is maintained by the data reader, it takes up fewer resources and performs more efficiently with small number of data operations. The dataset, on the other hand is more efficient when large number of updates are to be made to the database. All the updates are done in the local memory and are updated to the database in a batch. Since database connection remains open for the short time, the database management system does not get flooded with the incoming requests.
What are the performance considerations when using dataset?
Since no memory buffer is maintained by the data reader, it takes up fewer resources and performs more efficiently with small number of data operations. The dataset, on the other hand is more efficient when large number of updates are to be made to the database. All the updates are done in the local memory and are updated to the database in a batch.
Since database connection remains open for the short time, the database management system does not get flooded with the incoming requests.
However, since the dataset stores the records in the local buffer in the hierarchical form, it does take up more resources and may affect the overall performance of the application.
How to select dataset or data reader?
The data reader is more useful when you need to work with large number of tables, database in non-uniform pattern and you need not execute the large no. of queries on few particular table.
When you need to work on fewer no. of tables and most of the time you need to execute queries on these fewer tables, you should go for the dataset.
It also depends on the nature of application.
If multiple users are using the database and the database needs to be updated every time, you must not use the dataset. For this, .Net provides the connection oriented architecture. But in the scenarios where instant update of database is not required, dataset provides optimal performance by making the changes locally and connecting to database later to update a whole batch of data. This also reduces the network bandwidth if the database is accessed through network.
Disconnected data access is suited most to read only services. On the down side, disconnected data access architecture is not designed to be used in the networked environment where multiple users are updating data simultaneously and each of them needs to be aware of current state of database at any time (e.g., Airline Reservation System).
How XML is supported in ADO.Net?
The dataset is represented in the memory as an XML document. You can fill the dataset by XML and can also get the result in the form of XML. Since XML is an international and widely accepted standard, you can read the data using the ADO.Net in the XML form and pass it to other applications using Web Service.
These data consuming application need not be the essentially Dot Net based. They may be written with Java, C++ or any other programming language and running on any platform.
ADO.Net also contains some database specific classes. This means that different database system providers may provide classes (or drivers) optimized for their particular database system. The provider for such classes are called the Dot Net Framework Data Providers. Microsoft itself has provided the specialized and optimized classes for their SQL server database system. The name of these classes start with ‘Sql’ and these are contained in System.Data.SqlClient namespace.
Similarly, Oracle has also provided its classes (driver) optimized for Oracle DB System. Microsoft has also provided the general classes which can connect your application to any OLE supported database server. The name of these classes start with ‘OleDb’ and these are contained in System.Data.OleDb namespace. In fact, you can use OleDb classes to connect to SQL server or Oracle database but using the database specific classes generally provides optimized performance.
RELATED POST
ASP.NET INTERVIEW QUESTIONS AND ANSWERS PART ONE
ASP.NET INTERVIEW QUESTIONS AND ANSWERS PART TWO
ASP.NET INTERVIEW QUESTIONS AND ANSWERS PART THREE
ASP.NET INTERVIEW QUESTIONS AND ANSWERS PART FOUR
ASP.NET INTERVIEW QUESTIONS AND ANSWERS PART FIVE
ADO.NET INTERVIEW QUESTIONS AND ANSWERS PART ONE
ADO.NET INTERVIEW QUESTIONS AND ANSWERS PART TWO
You can also learn the concept of frame work concept in detail with questions and answers in the following place.
MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART ONE
MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART TWO
MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART THREE
MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART FOUR
MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART FIVE
MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART SIX
MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART SEVEN
MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART EIGHT
MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART NINE
MICROSOFT DOT NET FRAME WORK QUESTIONS AND ANSWERS PART TEN
No comments:
Post a Comment