21. Explain the architecture of ADO.NET in brief?
AD0.NET consists of two fundamental components: The DataSet, which is disconnected from the data source and does not need to know where the data that it holds is retrieved from.
The .net data provider, which allows you to connect your application to the data source and execute the SQL commands against it.
The data provider contains the Connection, Command, DataReader, and DataAdapter objects. TheConnection object provides connectivity to the database. The Command object provides access to database commands to retrieve and manipulate data in a database. The DataReader object retrieves data from the database in the readonly and forward-only mode. The DataAdapter object uses Command objects to execute SQL commands. The DataAdapter object loads the DataSet object with data and also updates changes that you have made to the data in the DataSet object back to the database.
22. Describe the disconnected architecture of ADO.NET's data access model?
ADO.NET maintains a disconnected database access model, which means, the application never remains connected constantly to the data source. Any changes and operations done on the data are saved in a local copy (dataset) that acts as a data source. Whenever, the connection to the server is re-established, these changes are sent back to the server, in which these changes are saved in the actual database or data source.
AD0.NET consists of two fundamental components: The DataSet, which is disconnected from the data source and does not need to know where the data that it holds is retrieved from.
The .net data provider, which allows you to connect your application to the data source and execute the SQL commands against it.
The data provider contains the Connection, Command, DataReader, and DataAdapter objects. TheConnection object provides connectivity to the database. The Command object provides access to database commands to retrieve and manipulate data in a database. The DataReader object retrieves data from the database in the readonly and forward-only mode. The DataAdapter object uses Command objects to execute SQL commands. The DataAdapter object loads the DataSet object with data and also updates changes that you have made to the data in the DataSet object back to the database.
22. Describe the disconnected architecture of ADO.NET's data access model?
ADO.NET maintains a disconnected database access model, which means, the application never remains connected constantly to the data source. Any changes and operations done on the data are saved in a local copy (dataset) that acts as a data source. Whenever, the connection to the server is re-established, these changes are sent back to the server, in which these changes are saved in the actual database or data source.
23. What are the pre-requisites for connection pooling? The prerequisites for connection pooling are as follows: There must be multiple processes to share the same connection describing the same parameters and security settings. The connection string must be identical. |
24. What are the usages of the Command object in ADO.NET?
The following are the usages of the Command object in AD0.NET:
The Command object in AD0.NET executes a command against the database and retrieves a DataReader orDataSet object.
Connection pooling refers to the task of grouping database connections in cache to make them reusable because opening new connections every time to a database is a time-consuming process. Therefore, connection pooling enables you to reuse already existing and active database connections, whenever required, and increasing the performance of your application.
You can enable or disable connection pooling in your application by setting the pooling property to either true or false in connection string. By default, it is enabled in an application.
The following are the usages of the Command object in AD0.NET:
The Command object in AD0.NET executes a command against the database and retrieves a DataReader orDataSet object.
- It also executes the INSERT, UPDATE, or DELETE command against the database.
- All the command objects are derived from the DbCommand class.
- The command object is represented by two classes: SqlCommand and OleDbCommand.
- The Command object provides three methods to execute commands on the database:
- The ExecuteNonQuery() method executes a Transact-SQL statement against the connection and returns the number of rows affected.
- The ExecuteScalar() method returns a single value from a database query.
- The ExecuteReader() method returns a result set by using the DataReader object.
Connection pooling refers to the task of grouping database connections in cache to make them reusable because opening new connections every time to a database is a time-consuming process. Therefore, connection pooling enables you to reuse already existing and active database connections, whenever required, and increasing the performance of your application.
You can enable or disable connection pooling in your application by setting the pooling property to either true or false in connection string. By default, it is enabled in an application.