Top 44 Ado.net Interview Questions
Q1. What Is Ado.Internet?
ADO.NET is part of the Microsoft .NET Framework. This framework provides the set of training that deal with records communique between various layers of the software structure and the database. It gives a non-stop get entry to to one-of-a-kind information source kinds which include SQL Server versions 7, 2000, 20@It also presents connectivity options to facts resources through OLE DB and XML. Connectivity may be hooked up with different databases like Oracle, MySQL and many others. As nicely.
ADO.NET has the potential to separate facts get entry to mechanisms, records manipulation mechanisms and data connectivity mechanisms.
ADO.NET introduces in conjunction with it the disconnected structure. In a disconnected structure, statistics may be stored in a DataSet. It includes vendors for connecting to databases, commands for execution and retrieval of results.
The training for ADO.NET are stored within the DLL System.Data.Dll.
Q2. What Is Linq?
Language Integrated Query or LINQ presents programmers and testers to query facts and it makes use of strongly type’s queries and consequences.
Q3. Describe The Disconnected Architecture Of Ado.Net's Data Access Model?
ADO.NET keeps a disconnected database get right of entry to version, which me, the utility never remains connected continuously to the facts supply. Any modifications and operations performed at the information are stored in a neighborhood copy (dataset) that acts as a records supply. Whenever, the connection to the server is re-mounted, these modifications are sent lower back to the server, wherein those modifications are saved inside the actual database or statistics supply.
Q4. What Are The Uses Of Stored Procedure?
Following are uses of Stored Procedure:
Improved Performance.
Easy to apply and keep.
Security.
Less effort and time taken to execute.
Less Network traffic.
Q5. How Can You Identify Whether Or Not Any Changes Are Made To The Dataset Object Since It Was Last Loaded?
The DataSet item offers the subsequent two techniques to music down the modifications:
The GetChanges() method - Returns the DataSet item, which is modified since it become loaded or since the AcceptChanges() approach become executed.
The HasChanges() approach - Indicates if any modifications passed off since the DataSet item was loaded or after a name to the AcceptChanges() technique changed into made.
If you need to revert all adjustments because the DataSet object was loaded, use the RejectChanges() method.
Q6. What Are Typed And Untyped Dataset?
Typed datasets use explicit names and statistics kinds for his or her contributors but untyped dataset makes use of table and columns for their members.
Q7. How Can You Add Or Remove Rows From The Datatable Object Of Dataset?
The DataRowCollection class defines the gathering of rows for the DataTable object in a DataSet. The DataTable elegance presents the NewRow() method to add a new DataRow to DataTable. The NewRow approach creates a brand new row, which implements the same schema as implemented to the DataTable. The following are the techniques furnished by the DataRowCollection item:
Add() - Adds a new row to DataRowCollection.
Remove()- Removes a DataRow item from DataRowCollection.
RemoveAt() - Removes a row whose location is exact by an index variety.
Q8. What Are The Pre-requirements For Connection Pooling?
The stipulations for connection pooling are as follows:
There have to be a couple of tactics to share the equal connection describing the same parameters and safety settings.
The connection string need to be equal.
Q9. What Is Partial Class?
A Partial class is a class that may be break up into two or more instructions. This me that a category may be physically separated into other parts of the magnificence in the identical namespace. All the parts need to use the partial key-word. All the opposite lessons need to also have the equal get right of entry to modifier. At the compile time, all of the partial classes can be handled as a unmarried elegance. Let us list a few benefits of having partial instructions.
Q10. How To Stop Running Thread?
Thread.Abort() feature stops the thread execution at any time.
Q11. What Are The Classes In System.Statistics.Commonplace Namespace?
There are two lessons worried in System.Data.Common Nameapce:
DataColumnMapping.
DataTableMapping.
Q12. What Are Different Layers Of Ado.Internet?
There are 3 specific layers of ADO.Net:
Presentation Layer
Business Logic Layer
Database Access Layer
Q13. What Is The Use Of Dataview?
User-defined view of a desk is contained in a DataView. A whole desk or a small section of table relying on some criteria may be provided with the aid of an object of the DataView elegance. You can use this elegance to sort and discover information inside DataTable.
The DataView class has the following methods:
Find() - Finds a row in a DataView by using sort key fee.
FindRows() - Uses the kind key price to in shape it with the columns of DataRowView objects. It returns an array of all of the corresponding items of DataRowView whose columns match with the type key cost.
AddNew() - Adds a brand new row to the DataView item.
Delete() - Deletes the specified row from the DataView item in step with the desired index.
Q14. 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?
You must set the DataSource property and speak to the DataBind() approach.Mention the namespace that is used to include .NET Data Provider for SQL server in .NET code.The System.Data.SqlClient namespace.
Q15. Explain In Brief Dataadapter Class In Ado.Net?
The DataAdapter class retrieves records from the database, shops information in a dataset, and displays the modifications made inside the dataset to the database. The DataAdapter magnificence acts as an intermediary for all of the communique between the database and the DataSet item. The DataAdapter Class is used to fill a DataTable or DataSet Object with statistics from the database using the Fill() approach. The DataAdapter elegance applies the changes made in dataset to the database via calling the Update() approach.
The DataAdapter elegance presents 4 houses that constitute the database command:
SelectCommand, InsertCommand, DeleteCommand, and UpdateCommand.
Q16. What Are All The Classes That Are Available In System.Records Namespace?
Following are the classes which might be available in System.Data Namespace:
Dataset.
DataTable.
DataColumn.
DataRow.
DataRelation.
Constraint.
Q17. What Are All Components Of Ado.Internet Data Provider?
Following are the additives of ADO.Net Data provider:
Connection item – Represents connection to the Database
Command item – Used to execute stored procedure and command on Database
ExecuteNonQuery – Executes command however doesn’t return any price
ExecuteScalar – Executes and returns unmarried fee
ExecuteReader – Executes and returns end result set
DataReader – Forward and study most effective recordset
DataAdapter – This acts as a bridge between database and a dataset.
Q18. What Are The Various Methods Provided By The Dataset Object To Generate Xml?
The diverse techniques supplied through the DataSet item to generate XML are:
ReadXml() - Reads XML file right into a DataSet item.
GetXml() - Returns a string containing an XML record.
WriteXml() - Writes an XML statistics to disk.
Q19. Explain The Architecture Of Ado.Net In Brief.
AD0.NET includes fundamental components:
The DataSet, that's disconnected from the records source and does no longer need to recognize wherein the statistics that it holds is retrieved from.
The .Net facts company, which permits you to connect your utility to the records source and execute the SQL instructions in opposition to it.
The records issuer includes the Connection, Command, DataReader, and DataAdapter objects.The Connection item affords connectivity to the database. The Command object gives get entry to to database instructions to retrieve and control statistics in a database. The DataReader item retrieves information from the database inside the readonly and ahead-handiest mode. The DataAdapter object makes use of Command objects to execute SQL instructions. The DataAdapter object hundreds the DataSet item with statistics and also updates adjustments which you have made to the information inside the DataSet item lower back to the database.
Q20. What Is The Difference Between Oledb Provider And Sqlclient?
With recognize to utilization, there is no difference between OLEDB Provider and SqlClient. The distinction lies in their overall performance. SqlClient is explicitly used to connect your software to SQL server at once, OLEDB Provider is widespread for diverse databases, along with Oracle and Access inclusive of SQL Server.Therefore, there will be an overhead which results in performance degradation.
Q21. What Is A Datareader Object?
The DataReader object enables in retrieving the data from a database in a ahead-only, study-simplest mode. The base magnificence for all the DataReader gadgets is the DbDataReader class.
The DataReader item is back as a result of calling the ExecuteReader() approach of the Command item. The DataReader object permits faster retrieval of information from databases and enhances the performance of .NET packages by using offering fast information get entry to pace. However, it's far much less preferred compared to the DataAdapter object because the DataReader object desires an Open connection till it completes studying all the rows of the desired desk.
An Open connection to study facts from massive tables consumes most of the device assets. When multiple patron packages concurrently get admission to a database with the aid of the use of the DataReader object, the overall performance of information retrieval and other associated techniques is considerably reduced. In this type of case, the database would possibly refuse connections to different .NET packages until other clients unfastened the resources.
Q22. Which Method Is Used To Sort The Data In Ado.Net?
Sort() technique of GridViewControl is used to sort the data in a datatable.
Q23. What Are All The Different Methods Under Sql Command?
There are one of a kind techniques underneath SqlCommand and they may be:
Cancel – Cancel the question
CreateParameter – returns SQL Parameter
ExecuteNonQuery – Executes and does not go back result set
ExecuteReader – executes and returns information in DataReader
ExecuteScalar – Executes and returns single fee
ExecuteXmlReader – Executes and return information in XMLDataReader object
ResetCommandTimeout – Reset Timeout property
Q24. 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 or DataSet object.
It also executes the INSERT, UPDATE, or DELETE command in opposition to the database.
All the command objects are derived from the DbCommand magnificence.
The command object is represented by way of instructions: SqlCommand and OleDbCommand.
The Command object gives three strategies to execute instructions on the database:
The ExecuteNonQuery() approach executes a Tract-SQL statement in opposition to the connection and returns the variety of rows affected.
The ExecuteScalar() approach returns a unmarried fee from a database query.
The ExecuteReader() method returns a end result set by using the use of the DataReader item.
Q25. Is It Possible To Load Multiple Tables In A Dataset?
Yes, it's miles possible to load a couple of tables in a single dataset.
Q26. How Can We Load Multiple Tables In To Dataset?
DataSet ds=new DataSet();
SqlDataAdapter dap=new SqlDataAdapter(Select * from ,);
dap.Fill(ds,”TableOne”);
SqlDataAdapter dap1=new SqlDataAdapter(Select * from ,);
dap1.Fill(ds,”tableTwo”);
Q27. Which Properties Are Used To Bind A Datagridview Control?
The DataSource property and the DataMember belongings are used to bind a DataGridView control.
Q28. What Is The Meaning Of Object Pooling?
Object pooling is a idea of storing a pool (organization) of objects in memory that may be reused later as wanted. Whenever, a new object is needed to create, an item from the pool may be allotted for this request; thereby, minimizing the item creation. A pool also can check with a group of connections and threads. Pooling, therefore, allows in minimizing using device sources, improves gadget scalability, and performance.
Q29. What Are The Methods Of Xml Dataset Object?
There are various methods of XML dataset item:
GetXml() – Get XML statistics in a Dataset as a single string.
GetXmlSchema() – Get XSD Schema in a Dataset as a unmarried string.
ReadXml() – Reads XML data from a report.
ReadXmlSchema() – Reads XML schema from a report.
WriteXml() – Writes the contents of Dataset to a record.
WriteXmlSchema() – Writes XSD Schema right into a record.
Q30. What Are The Parameters That Control Most Of Connection Pooling Behaviours?
The parameters that control most of connection pooling behaviors are as follows:
Connect Timeout
Max Pool Size
Min Pool Size
Pooling
Q31. What Is The Difference Between Dataset.Clone And Dataset.Replica?
Dataset.Clone item copies shape of the dataset such as schemas, members of the family and constraints. This will not replica statistics inside the desk.
Dataset.Replica – Copies each structure and statistics from the desk.
Q32. Which Is The Best Method To Get Two Values From The Database?
ExecuteNonQuery is the first-class approach to get two values from the database.
Q33. Do We Use Stored Procedure In Ado.Net?
Yes, stored tactics are utilized in ADO.Net and it can be used for commonplace repetitive functions.
Q34. What Is The Default Time Out For Sql Command.Commandtimeout Property?
The default timeout of Sqlcommand. CommandTimeout belongings is 30 Seconds.
Q35. What Are The Data Providers In Ado.Internet?
Following are the Data Providers used in ADO.Net:.
MS SQL Server.
OLEDB.
ODBC.
Q36. What Are All The Different Authentication Techniques Used To Connect To Ms Sql Server?
SQL Server ought to authenticate before performing any pastime in the database. There are varieties of authentication:
Windows Authentication – Use authentication the use of Windows domain money owed only.
SQL Server and Windows Authentication Mode – Authentication provided with the mixture of both Windows and SQL Server Authentication.
Q37. What Are All The Commands Used With Data Adapter?
DataAdapter is used to retrieve facts from a information supply .Insertcommand, UpdateCommand and DeleteCommand are the instructions object utilized in DataAdapter to control replace on the database.
Q38. What Are The Differences Between Oledb And Sqlclient Providers?
OLEDB provider is used to access any database and offers flexibility of converting the database at any time. SQLClient issuer is used to get right of entry to best SQL Server database but it affords notable performance than OLEDB issuer even as connecting with SQL Server database.
Q39. What Is The Role Of The Dataset Object In Ado.Net?
One of the primary aspect of ADO.NET is the DataSet object, which constantly remains disconnected from the database and reduces the burden on the database.
Q40. What Is The Difference Between Command And Commandbuilder Object?
Command is used to execute all type of queries like DML and DDL. DML is not anything but Insert, Update and Delete. DDL are like Create and drop tables.
Command Builder item is used to construct and execute DML queries like Create and Drop Tables.
Q41. What Is Connection Pooling?
Connection pooling refers to the undertaking of grouping database connections in cache to make them reusable due to the fact opening new connections each time to a database is a time-ingesting procedure. Therefore, connection pooling enables you to reuse already present and energetic database connections, on every occasion required, and increasing the overall performance of your application.
You can allow or disable connection pooling for your application through putting the pooling belongings to both actual or false in connection string. By default, it's miles enabled in an application.
Q42. Which Object Is Used To Add Relationship Between Two Datatables?
DataRelation item is used to feature dating between two or extra datatable items.
Q43. What Are The Different Execute Methods Of Ado.Internet?
Following are distinct execute strategies of ADO.Net command item:
ExecuteScalar – Returns single fee from the dataset
ExecutenonQuery – Returns resultset from dataset and it has multiple values
ExecuteReader – Forwardonly resultset
ExecuteXMLReader – Build XMLReader object from a SQL Query
Q44. What Is The Difference Between The Clone() And Copy() Methods Of The Dataset Class?
The Clone() method copies best the structure of a DataSet. The copied structure includes all the relation, constraint, and DataTable schemas used by the DataSet. The Clone() approach does now not copy the statistics, which is saved in the DataSet.
The Copy() method copies the structure in addition to the information saved within the DataSet.

