ADO.Net Interview Questions & Answers

4 avg. rating (80% score) - 1 votes

ADO.Net Interview Questions & Answers

ADO.Net is one of the data access technology from Microsoft .NET Framework. Using a set of components ADO.Net provides a communication between relational and non-relational systems. It divides the data access from data manipulation into discrete components which can be used individually. One can check the availability of the job across cities including Mumbai, Delhi, Bangalore, Pune and Hyderabad. ADO.Net role consists of handling set of components that programmers used to access data and services using ASP, SQL, HTML. Wisdomjobs has interview questions which are exclusively designed for job seekers to assist them in clearing job interviews. ADO.Net job interview questions and answers are useful for developers and administrators to attend job interviews and get selected for ADO.Net job position.

ADO.Net Interview Questions

ADO.Net Interview Questions
    1. Question 1. What Is Ado.net?

      Answer :

      ADO.NET is a part of the Microsoft .NET Framework. This framework provides the set of classes that deal with data communication between various layers of the software architecture and the database. It provides a continuous access to different data source types such as SQL Server versions 7, 2000, 2005. It also provides connectivity options to data sources through OLE DB and XML. Connectivity may be established with other databases like Oracle, MySQL etc. as well.
      ADO.NET has the ability to separate data access mechanisms, data manipulation mechanisms and data connectivity mechanisms.
      ADO.NET introduces along with it the disconnected architecture. In a disconnected architecture, data may be stored in a DataSet. It contains providers for connecting to databases, commands for execution and retrieval of results.
      The classes for ADO.NET are stored in the DLL System.Data.dll.

    2. Question 2. What Is The Meaning Of Object Pooling?

      Answer :

      Object pooling is a concept of storing a pool (group) of objects in memory that can be reused later as needed. Whenever, a new object is required to create, an object from the pool can be allocated for this request; thereby, minimizing the object creation. A pool can also refer to a group of connections and threads. Pooling, therefore, helps in minimizing the use of system resources, improves system scalability, and performance.

    3. Question 3. Which Properties Are Used To Bind A Datagridview Control?

      Answer :

      The DataSource property and the DataMember property are used to bind a DataGridView control.

    4. Question 4. What Property Must Be Set And What Method Must Be Called In Your Code To Bind The Data From Some Data Source To The Repeater Control?

      Answer :

      You must set the DataSource property and call the DataBind() method.Mention the namespace that is used to include .NET Data Provider for SQL server in .NET code.The System.Data.SqlClient namespace.

    5. Question 5. What Is The Difference Between Oledb Provider And Sqlclient?

      Answer :

      With respect to usage, there is no difference between OLEDB Provider and SqlClient. The difference lies in their performance. SqlClient is explicitly used to connect your application to SQL server directly, OLEDB Provider is generic for various databases, such as Oracle and Access including SQL Server.Therefore, there will be an overhead which leads to performance degradation.

    6. Question 6. How Can We Load Multiple Tables In To Dataset?

      Answer :

      DataSet ds=new DataSet();
      SqlDataAdapter dap=new SqlDataAdapter(Select * from ,);
      dap.Fill(ds,”TableOne”);
      SqlDataAdapter dap1=new SqlDataAdapter(Select * from ,);
      dap1.Fill(ds,”tableTwo”);

    7. Question 7. What Is Partial Class?

      Answer :

      A Partial class is a class that can be split into two or more classes. This means that a class can be physically separated into other parts of the class within the same namespace. All the parts must use the partial keyword. All the other classes should also have the same access modifier. At the compile time, all the partial classes will be treated as a single class. Let us list some advantages of having partial classes.

    8. Question 8. What Is The Role Of The Dataset Object In Ado.net?

      Answer :

      One of the major component of ADO.NET is the DataSet object, which always remains disconnected from the database and reduces the load on the database.

    9. Question 9. What Is A Datareader Object?

      Answer :

      The DataReader object helps in retrieving the data from a database in a forward-only, read-only mode. The base class for all the DataReader objects is the DbDataReader class.
      The DataReader object is returned as a result of calling the ExecuteReader() method of the Command object. The DataReader object enables faster retrieval of data from databases and enhances the performance of .NET applications by providing rapid data access speed. However, it is less preferred as compared to the DataAdapter object because the DataReader object needs an Open connection till it completes reading all the rows of the specified table. 
      An Open connection to read data from large tables consumes most of the system resources. When multiple client applications simultaneously access a database by using the DataReader object, the performance of data retrieval and other related processes is substantially reduced. In such a case, the database might refuse connections to other .NET applications until other clients free the resources.

    10. Question 10. How Can You Identify Whether Or Not Any Changes Are Made To The Dataset Object Since It Was Last Loaded?

      Answer :

      The DataSet object provides the following two methods to track down the changes: 
      The GetChanges() method - Returns the DataSet object, which is changed since it was loaded or since the AcceptChanges() method was executed.
      The HasChanges() method - Indicates if any changes occurred since the DataSet object was loaded or after a call to the AcceptChanges() method was made.
      If you want to revert all changes since the DataSet object was loaded, use the RejectChanges() method.

    11. Question 11. What Are The Various Methods Provided By The Dataset Object To Generate Xml?

      Answer :

      The various methods provided by the DataSet object to generate XML are:

      • ReadXml() - Reads XML document into a DataSet object.
      • GetXml() - Returns a string containing an XML document.
      • WriteXml() - Writes an XML data to disk.

    12. Question 12. What Is Connection Pooling?

      Answer :

      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.

    13. Question 13. What Are The Pre-requisites For Connection Pooling?

      Answer :

      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.

    14. Question 14. What Are The Usages Of The Command Object In Ado.net?

      Answer :

      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 or DataSet 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.

    15. Question 15. Explain The Architecture Of Ado.net In Brief.

      Answer :

      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.The Connection 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.

    16. Question 16. Describe The Disconnected Architecture Of Ado.net's Data Access Model?

      Answer :

      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.

    17. Question 17. What Is The Difference Between The Clone() And Copy() Methods Of The Dataset Class?

      Answer :

      The Clone() method copies only the structure of a DataSet. The copied structure includes all the relation, constraint, and DataTable schemas used by the DataSet. The Clone() method does not copy the data, which is stored in the DataSet. 
      The Copy() method copies the structure as well as the data stored in the DataSet.

    18. Question 18. What Is The Use Of Dataview?

      Answer :

      User-defined view of a table is contained in a DataView. A complete table or a small section of table depending on some criteria can be presented by an object of the DataView class. You can use this class to sort and find data within DataTable.
      The DataView class has the following methods:
      Find() - Finds a row in a DataView by using sort key value.
      FindRows() - Uses the sort key value to match it with the columns of DataRowView objects. It returns an array of all the corresponding objects of DataRowView whose columns match with the sort key value.
      AddNew() - Adds a new row to the DataView object.
      Delete() - Deletes the specified row from the DataView object according to the specified index.

    19. Question 19. What Are The Parameters That Control Most Of Connection Pooling Behaviours?

      Answer :

      The parameters that control most of connection pooling behaviors are as follows:

      • Connect Timeout
      • Max Pool Size
      • Min Pool Size
      • Pooling

    20. Question 20. How Can You Add Or Remove Rows From The Datatable Object Of Dataset?

      Answer :

      The DataRowCollection class defines the collection of rows for the DataTable object in a DataSet. The DataTable class provides the NewRow() method to add a new DataRow to DataTable. The NewRow method creates a new row, which implements the same schema as applied to the DataTable. The following are the methods provided by the DataRowCollection object:
      Add() - Adds a new row to DataRowCollection.
      Remove()- Removes a DataRow object from DataRowCollection.
      RemoveAt() - Removes a row whose location is specified by an index number.

    21. Question 21. Explain In Brief Dataadapter Class In Ado.net?

      Answer :

      The DataAdapter class retrieves data from the database, stores data in a dataset, and reflects the changes made in the dataset to the database. The DataAdapter class acts as an intermediary for all the communication between the database and the DataSet object. The DataAdapter Class is used to fill a DataTable or DataSet Object with data from the database using the Fill() method. The DataAdapter class applies the changes made in dataset to the database by calling the Update() method. 
      The DataAdapter class provides four properties that represent the database command: 
      SelectCommand, InsertCommand, DeleteCommand, and UpdateCommand.

    22. Question 22. What Are Different Layers Of Ado.net?

      Answer :

      There are three different layers of ADO.Net:

      • Presentation Layer
      • Business Logic Layer
      • Database Access Layer

    23. Question 23. What Are The Data Providers In Ado.net?

      Answer :

      Following are the Data Providers used in ADO.Net:.

      • MS SQL Server.
      • OLEDB.
      • ODBC.

    24. Question 24. What Are The Uses Of Stored Procedure?

      Answer :

      Following are uses of Stored Procedure:

      • Improved Performance.
      • Easy to use and maintain.
      • Security.
      • Less time and effort taken to execute.
      • Less Network traffic.

    25. Question 25. What Is The Default Time Out For Sql Command.commandtimeout Property?

      Answer :

      The default timeout of Sqlcommand. CommandTimeout property is 30 Seconds.

    26. Question 26. What Are The Classes In System.data.common Namespace?

      Answer :

      There are two classes involved in System.Data.Common Nameapce:

      • DataColumnMapping.
      • DataTableMapping.

    27. Question 27. What Is Linq?

      Answer :

      Language Integrated Query or LINQ provides programmers and testers to query data and it uses strongly type’s queries and results.

    28. Question 28. What Are Typed And Untyped Dataset?

      Answer :

      Typed datasets use explicit names and data types for their members but untyped dataset uses table and columns for their members.

    29. Question 29. How To Stop Running Thread?

      Answer :

      Thread.Abort() function stops the thread execution at any time.

    30. Question 30. Which Method Is Used To Sort The Data In Ado.net?

      Answer :

      Sort() method of GridViewControl is used to sort the data in a datatable.

    31. Question 31. Which Object Is Used To Add Relationship Between Two Datatables?

      Answer :

      DataRelation object is used to add relationship between two or more datatable objects.

    32. Question 32. Which Is The Best Method To Get Two Values From The Database?

      Answer :

      ExecuteNonQuery is the best method to get two values from the database.

    33. Question 33. What Are All The Classes That Are Available In System.data Namespace?

      Answer :

      Following are the classes that are available in System.Data Namespace:

      • Dataset.
      • DataTable.
      • DataColumn.
      • DataRow.
      • DataRelation.
      • Constraint.

    34. Question 34. What Are All Components Of Ado.net Data Provider?

      Answer :

      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 recordset
      DataAdapter – This acts as a bridge between database and a dataset.

    35. Question 35. What Are The Differences Between Oledb And Sqlclient Providers?

      Answer :

      OLEDB provider is used to access any database and provides flexibility of changing the database at any time. SQLClient provider is used to access only SQL Server database but it provides excellent performance than OLEDB provider while connecting with SQL Server database.

    36. Question 36. What Are The Different Execute Methods Of Ado.net?

      Answer :

      Following are different execute methods of ADO.Net command object:
      ExecuteScalar – Returns single value from the dataset
      ExecutenonQuery – Returns resultset from dataset and it has multiple values
      ExecuteReader – Forwardonly resultset
      ExecuteXMLReader – Build XMLReader object from a SQL Query

    37. Question 37. What Are All The Commands Used With Data Adapter?

      Answer :

      DataAdapter is used to retrieve data from a data source .Insertcommand, UpdateCommand and DeleteCommand are the commands object used in DataAdapter to manage update on the database.

    38. Question 38. What Are All The Different Methods Under Sql Command?

      Answer :

      There are different methods under SqlCommand and they are:
      Cancel – Cancel the query
      CreateParameter – returns SQL Parameter
      ExecuteNonQuery – Executes and does not return result set
      ExecuteReader – executes and returns data in DataReader
      ExecuteScalar – Executes and returns single value
      ExecuteXmlReader – Executes and return data in XMLDataReader object
      ResetCommandTimeout – Reset Timeout property

    39. Question 39. What Is The Difference Between Dataset.clone And Dataset.copy?

      Answer :

      Dataset.clone object copies structure of the dataset including schemas, relations and constraints. This will not copy data in the table.
      Dataset.copy – Copies both structure and data from the table.

    40. Question 40. What Is The Difference Between Command And Commandbuilder Object?

      Answer :

      Command is used to execute all kind of queries like DML and DDL. DML is nothing but Insert, Update and Delete. DDL are like Create and drop tables.
      Command Builder object is used to build and execute DML queries like Create and Drop Tables.

    41. Question 41. Is It Possible To Load Multiple Tables In A Dataset?

      Answer :

      Yes, it is possible to load multiple tables in a single dataset.

    42. Question 42. Which Provider Is Used To Connect Ms Access, Oracle, Etc…?

      Answer :

      OLEDB Provider and ODBC Provider are used to connect to MS Access and Oracle. Oracle Data Provider is also used to connect exclusively for oracle database.

    43. Question 43. Do We Use Stored Procedure In Ado.net?

      Answer :

      Yes, stored procedures are used in ADO.Net and it can be used for common repetitive functions.

    44. Question 44. What Are The Methods Of Xml Dataset Object?

      Answer :

      There are various methods of XML dataset object:
      GetXml() – Get XML data in a Dataset as a single string.
      GetXmlSchema() – Get XSD Schema in a Dataset as a single string.
      ReadXml() – Reads XML data from a file.
      ReadXmlSchema() – Reads XML schema from a file.
      WriteXml() – Writes the contents of Dataset to a file.
      WriteXmlSchema() – Writes XSD Schema into a file.

    45. Question 45. What Are All The Different Authentication Techniques Used To Connect To Ms Sql Server?

      Answer :

      SQL Server should authenticate before performing any activity in the database. There are two types of authentication:
      Windows Authentication – Use authentication using Windows domain accounts only.
      SQL Server and Windows Authentication Mode – Authentication provided with the combination of both Windows and SQL Server Authentication.

Asp.net Tutorial

Ado.net Interview Questions

Ado.net Practice Tests

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

ASP.NET Tutorial