Latest Questions
Post Top Ad
Your Ad Spot
Friday, June 14, 2019

45 Top ADO.NET Interview Questions and Answers{Updated}

ADO.NET Interview Questions and Answers for experienced PDF, Read commonly asked ADO.NET Job Interview Questions with Answer PDF for Freshers.

Read ADO.NET Interview Questions and Answers

How to find the count of records in a dataset?
we can get the count of the records.

what is data Adapter?
Data adapter is a bridge between Connection and DataSet, Data adapter in passing the SQL query and fills in a dataset

What is Isolation?
A transaction is a unit of isolation? allowing concurrent transactions to behave as though each was the only transaction running in the system.
Isolation requires that each transaction appear to be the only transaction manipulating the data store, even though other transactions may be running at the same time. A transaction should never see the intermediate stages of another transaction.
Transactions attain the highest level of isolation when they are serializable. At this level, the results obtained from a set of concurrent transactions are identical to the results obtained by running each transaction serially.
Because a high degree of isolation can limit the number of concurrent transactions, some applications reduce the isolation level in exchange for better throughput.

What is Atomicity?
A transaction is a unit of work in which a series of operations occur between the BEGIN TRANSACTION and END TRANSACTION statements of an application. A transaction executes exactly once and is atomic?
all the work is done or none of it is.
Operations associated with a transaction usually share a common intent and are interdependent.
By performing only a subset of these operations, the system could compromise the overall intent of the
transaction. Atomicity eliminates the chance of processing a subset of operations.

Explain acid properties?
The term ACID conveys the role transactions play in mission-critical applications. Coined by transaction processing pioneers, ACID stands for atomicity, consistency, isolation, and durability.
These properties ensure predictable behavior, reinforcing the role of transactions as all-or-none propositions designed to reduce the management load when there are many variables.

What are the provider and namespaces being used to access the oracle database?
The provider name is oledb and the namespace is

What provider use by default? uses no Dataprovider by default and this is an absolutely correct answer. there is no other choice for this question

What we do with the object of dataset after using it? Can we dispose of it or can we set it nothing? Is it must or not?
we use dispose

What are the two fundamental objects in ADO.NET?
DataReader and Dataset are the two fundamental objects in ADO.NET

What are the different row versions available in the table?
There are four types of Row versions.
The current values for the row. This row version does not exist for rows with a RowState of Deleted.
Default :
The row the default version for the current DataRowState. For a DataRowState value of Added,
Modified or Current, the default version is Current. For a DataRowState of Deleted, the version is Original.
For a DataRowState value of Detached, the version is Proposed.
Original: The row contains its original values.
The proposed values for the row. This row version exists during an edit operation on a row, or for a
row that is not part of a DataRowCollection.

What is the data access layer?
Data Access layer is actually a part of Architecture layer. It has 2 tier,3 tier or N tier Layer. Generally, we use 3 tier Layer 1) Presentation layer, Business Logic layer and the Data Access Layer. Data Access layer is a medium to talk between the database and the Business Logic layer.
It helps to maintain flexibility, reusability and even security also. Insecurity, SQL Injection can be stopped with 3 tier Architecture.

If a table contains 20000 records. In a page at each time 100 records to be displayed. What are the steps u will take to improve performance? will you use dataset or data reader?
we have to use a dataset because on using data reader forward only paging can be achieved.
Suppose if you are at 1000 page and you want to go back to 999th page, if you use DataReader it cannot be achieved since it does not support backward navigation.
Dataset supports forward and backward navigation.

what is bubbled event can u pls explain?
All heavy controls like grid view, data grid or data list, repeater controls contain the child controls like button or link button, when we click this button then the event will be raised, that events are handled by parent controls,that is called event bubbling,means event is bubbled from bottom(child)to up(parent).

What is different between the SqlCommand object and Command Behavior Object?
DO.NET Command Object – The Command object is similar to the old ADO command object.
It is used to store SQL statements that need to be executed against a data source.
The Command object can execute SELECT statements, INSERT, UPDATE, or DELETE statements, stored procedures, or any other statement understood by the database.

Can dataReader hold data from multiple tables?
data reader can hold data from multiple tables and datareader can hold more than one table.
string query=”select * from employee; select * from student”;
sqlcommand cmd=new sqlcommand(query, connection);
sqldatareader dr=cmd.executeReader();

I loaded the dataset with a table of 10 records. One of the records is deleted from the backend, How do you check whether all the 10 records were present while updating the data(Which event and steps) and throw the exception.
By Using the Transactions we can check the Exact Numbers of the rows to be updated and if the updation fails then the Transaction will be rollbacked.

what is typed and untyped dataset?
A DataSet can be Typed or Untyped. The difference between the two lies in the fact that a Typed DataSet has a schema and an Untyped DataSet does not have one. It should be noted that the Typed Datasets have more support in Visual Studio.

How to call the SQL commands asynchronously in ADO.NET version 2.0?
these come with Begin and End like Beginexecutescalr() Endexecutescalar()…….
by using these command we can achieve async comm in

How to copy the contents from one table to another table and how to delete the source table in
it is possible
DataSet ds;
Datatable dt = ds.Tables[0].copy();
//now the structure and data are copied into ‘dt’
//now the source is removed from the ‘ds’

How to find the given query is optimized one or not?
First Execute SQL Queries in Query Analyzer, see How much time 2 take Execute, if Less then the ur desired Time, then it will Optimize query

Why can not we use Multiple inheritance and garbage collector parallelly in .net?
.net doesn’t support the multiple inheritances, perhaps you may talk about multi-level inheritance.
In the latter case, if a class is inherited from another class, at the time of creating an instance, it will obviously give a call to its base class constructor (ie bottom – top approach). Likewise, the constructor execution is taking place in top-down approach (ie. base class constructor is executed and the derived class constructor is executed).
So for GC, it will collect only when an object does not have any reference. As we see previously, the derived is constructed based on the base class. There is a reference is set to be. Obviously, GC cannot be collected.

Difference between SqlCommand and SqlCommandBuilder?
a) SQLCommand is used to execute all kind of SQL queries like DML(Insert, update, Delete) & DDL like(Create table, drop table, etc)
b)SQLCommandBuilder object is used to build & execute SQL (DML) queries like select, insert, update & delete.

why edit is not possible in a repeater?
It has no such feature.

Do the SQLClient and OLEdb class share the same functionality?
No, each has its own functionality,
ex: for SQL client, there is a SqlConnection object
and for an oledb client, there is OleDBConnection

What is the difference between the data reader and the data set?
1) DataSet is a disconnected object type. It uses XML to store data.
2) It fetches all data from the data source at a time
3) Modifications can be updated to the actual database
4) It will reduce application performance.

What is the difference between the data reader and the data adapter?
DataReader is a forward-only and read-only cursor type if you are accessing data through DataRead it shows the data on the web form/control but you can not perform the paging feature on that record(because it’s forward the only type). Reader is best fit to show the Data (where no need to work on data)DataAdapter is not only connected with the Database(through Command object) it provide four types of command (InsertCommand, UpdateCommand, DeleteCommand, SelectCommand), It supports to the disconnected Architecture of .NET show we can populate the records to the DataSet. whereas DataAdapter is best fit to work on data.

what are the advantages and disadvantages of using data list?
Adv: the DataList’s display is defined via templates, DataList allows for much more customization of the rendered HTML markup, by which it is more user-friendly displays of data.
adding such functionality with the DataList takes more development time than with the DataGrid, as,
1. The Edit/Update/Cancel buttons that can be created in a DataGrid via the EditCommandColumn column type must be manually added to the DataList, and
2. The DataGrid BoundColumn column types automatically use a TextBox Web control for the editing interface, whereas with the DataList you must explicitly specify the editing interface for the item being edited via the EditItemTemplate.
3. we can’t do the paging and sorting with data list controls.

What is a Partial class?
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.

How do you connect to SQL Server Database without using SQL client?
you can connect SQL using oledbname space.

What are the steps to connect to a database?
1. Create a connection. This requires a connection string, which can be given declaratively or put in a well-defined place like the .config files. Advantage of keeping in .config files is that it enables the use of Connection Pooling by .Net framework, else even one small change in the connection string will cause CLR to think it’s not the same connection and will instantiate new connection for another request.
2. Open the connection and keep it open until done, typically done as using (con) { //use }
3. If using connected data model, create a SqlCommand object, decorate it with the desired command, command type (stored procedure for eg), add any parameters and their values to the command, and then consume the command by using ExcuteReader or ExecuteScalar. In case of ExecuteReader, we will get back a handle to a fast-forward, read-only pointer to the recordset. We can also decorate Command object with multiple recordsets in 2.0 and execute one by one (MARS – Multiple Active Record Sets)
4. If using disconnected data model, create a DataAdapter object, decorate it with desired SELECT, INSERT, UPDATE, DELETE commands, add parameters as necessary and then fill up a DataSet or DataTable using the DataAdapter. Subsequent SQL can be executed using insert, update, delete commands on the dataset.

How do you update a Dataset in ADO.Net and How do you update database through Dataset?
a. Update a dataset;
Dataset ds = new dataset();
SqlDataAdapter adp = new SqlDataAdapter(Query,connection);
Again you can add/update Dataset as below
SqlDataAdapter adp1 = new SqlDataAdapter(Query1,connection);
b. Update database through dataset.
SqlCommandBuilder mySqlCommandBuilder = new SqlCommandBuilder(mySqlDataAdapter);
Foreach(datarow dr in ds.table[0].rows)
Dr[“column Name”] = “value”;

What is a Delegate?
Delegate is an important element of C# and is extensively used in every type of .NET application. A delegate is a class whose object (delegate object) can store a set of references to methods.

What is a connection String?
connection String – a string which contains the address of the database we want to connect to.

How can we load multiple tables into Dataset?
DataSet ds=new DataSet();
SqlDataAdapter dap=new SqlDataAdapter(Select * from <tablename>,<connection1>);
SqlDataAdapter dap1=new SqlDataAdapter(Select * from <tablename>,<connection1>);

Which one of the following objects is a high-level abstraction of the Connection and Command objects in ADO.NET?
DataReader DataSet DataTable DataView DataAdapter
Answer: DataAdapter

What is the ExecuteScalar method?
// Summary:
Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.
// Returns:
The first column of the first row in the result set, or a null reference (Nothing in Visual Basic) if the result set is empty.

Explain ExecuteNonQuery?
// Summary:
// Executes a Transact-SQL statement against the connection and returns the number of rows affected.
// Returns:
// The number of rows affected.

How can I retrieve two tables of data at a time by using data reader?
Data reader read and forward only, how is it possible to get 2 tables of data at a time?
yes this is possible
If we execute 2 select commands either in a stored procedure or in select command and then executereader method fired of the command object. it returns 2 tables in DataReader.
like :
string str=”Select * from a;select * from b”;
Now it returns 2 tables in datareader (dr).

If we are not returning any records from the database, which method is to be used?
There is a method called Execute Non-Query. This method executes the Update, Delete, etc. This does not return any rows but will give the number of rows affected.

Can we do database operations without using any of the objects?
No its not at all possible.

can we connect two data adapters to the same data source using a single connection at the same time?
yes, we can connect two data adapters to the same data source using a single connection at the same time.
There is a technology in 2.0 called MARS usinng Mars in connection string we can do it.
for eg:
cn.ConnectionString = “server=(local); database=employee; integrated security=sspi; MultipleActiveResultSets=True”;

What is ADO.NET?
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 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.

Post Top Ad

Your Ad Spot