Top 30 ADO.NET Interview Questions and Answers


11) What are the various objects in a DataSet?

Dataset has a collection of Tables which has the DataTable collection which further has DataRow & DataColumn objects collections.

Dataset also has collections for the primary keys, constraints, and default values called as constraint collection.

There is also a default view object for each table. This used to create a Data View object based on the table so that the data can be searched, filtered or otherwise manipulated while displaying the records.

12) Write down a sample ADO.Net Connection to SQL Server ?
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
using System.Data.SqlClient;

try
{
                            // Opening connection
                            string Connection = "server=localhost; uid=techstudy-pc; password=myPass; database = SampleDB";
    SqlConnection con = new SqlConnection(Connection);
    conn.Open();
}
catch ( Exception ex )
{
                            // Log Exceptions
}

finally
{
    con.Close ( ) ; // Close the connection
}
13) What is the use of “DataView” ?

Dataview is used for sorting & filtering data in a datatable.

1
2
3
//Example
DataTable Student = GetTable();
Student.DefaultView.Sort = "FirstName";
14) What’s difference between “Pessimistic” & “Optimistic” ?
Pessimistic locking

Pessimistic locking is used when the user wants to update a record in a database & the user want to prevent other users from updating the same record at the Same time another user can only view the data when there is pessimistic locking.


Optimistic locking

Optimistic locking is used to improve concurrent operations on a record by allowing many users to update the same record. The record is only locked when updating the record. Optimistic locking has been widely used by programmers.

15) What is Connection pooling in ADO.NET?

Connection pooling in ADO.NET is used to reduce the overhead of creating a connection to the database. A connection pool will have a predefined number of minimum and maximum connections to the database which will be used by the application to execute queries. Once application completes a transaction, the connection will be released and the connection will go back to connection pool rather than connection getting closed.

     

16) What are the parameters that control most of connection pooling behaviors?

Max Pool Size – Maximum size of connection pool
Min Pool Size – Minimum no of connections that will be created in connection pool at application start up.
Pooling – To set connection pooling to on or off.
Connection Timeout – Wait period for a new connection.

17) What is Maximum Pool Size in ADO.NET Connection String ?

Default max pool size in ADO.NET is 100.

18) How to enable and disable connection pooling?

To enable connection pooling "Use Pooling = true" in connection pooling

To disable connection pooling set Pooling = false in connection pooling

19) What is the difference between Dataset.clone and Dataset.Copy?
Dataset.clone

DataSet.Clone copies only the structure of the DataSet. In other words, the Clone method of the DataSet class copies only the schema of a DataSet object.

Dataset.Copy

DataSet.Copy copies both the structure (tables, relations etc) and the data.In other words, the Copy method of the DataSet class copies both the structure and data of a DataSet object.

20) What are different layers of ADO.Net?

Database Access Layer

Business Logic Layer

Presentation Layer

     


  « 1 2 3 »  





Related Topics




Popular Posts