ADO.NET Interview Questions and Answers (445) - Page 1

Can you edit data in Repeater control?

No, it is readonly and forward only control so we can't edit data in repeater control.
Which ADO.NET object is very fast in getting data from database?

SqlDataReader object. (Note: Even datasets also use SqlDataReader objects internally for retriving data from database.)
Can you edit data in the Repeater control?

No, it just reads the information from its data source
Diff Data Grid and Repeater

Datagrid is
* one which has advanced features and lets you do lot many things like paging and sorting your data without much effort.
* DataGrid can hold text data, but not linked or embedded objects.


Whereas a DataRepeater is
* which does not have the paging feature but we can do it by coding.
* one which can hold other controls and can embed objects.
* It can embed a Datagrid within it but not viceversa.

Apart from this a Data Repeater
--is used in places where you need more control over the rendering of your data
-- have very flexible templates that give you total control over the formatting of your data
What is the purpose of connection pooling in ADO.NET?

Connection pooling enables an application to use a connection from a pool of connections that do not need to be re-established for each use. Once a connection has been created and placed in a connection pool, an application can reuse that connection without performing the complete connection creation process.
What is a Linked Server?

A linked server configuration enables SQL Server to execute commands against OLE DB data sources on remote servers. Linked Servers is a concept in SQL Server by which we can add other SQL Server to a Group and query both the SQL Server dbs using T-SQL Statements.
Linked servers offer the following advantages:


1. Remote server access.
2. The ability to issue distributed queries, updates, commands, and transactions on heterogeneous data sources across the enterprise.
3. The ability to address diverse data sources similarly.

With a linked server, you can create very clean, easy to follow, SQL statements that allow remote data to be retrieved, joined and combined with local data. Stored Procedure sp_addlinkedserver, sp_addlinkedsrvlogin will be used add new Linked Server.
Can DataAdapter object accept DataTable as parameter in Fill method?

Yes,

DataAdapter object can accept either DataTable or DataSet as parameter to fill data from database.

eg.

SqlDataAdapter dAd = new SqlDataAdapter();

DataTable dTable = new DataTable();
DataSet dSet = new DataSet();
----
---
dAd.Fill(dTable); // will also work
dAd.Fill(dSet); // will also work


We should only use DataSet as parameter when we are expecting more than one result set is being returned from database.
How to create a DataView from DataTable?

In order to create a DataView from a DataTable, use instantiate the DataView object by passing DataTable as parameter in the constructor.

eg.

DataView dView = new DataView(dTable);

Name some of the top level objects which ADO consists?

1. Connection object is responsible for creating a connection to the database.
2. Record object represents data which is not from the database.
3. Parameter object represents a sql parameter
4. Stream object is responsible to represent data from a text page or web page.
Explain about the relationship of XML and ADO.NET?

ADO.NET utilizes the power of XML by providing disconnected access to data. This is designed with the help of XML classes in .NET Framework which form the components of single architecture.
Explain about Data access objects or DAO?

DAO is used for database access on windows platform. It creates a work space object in which applications or operations are performed. There are two types of database engines they are Jet database engine and ODBC direct database engine.
What are the advantage of ADO.Net?

• ADO.NET Does Not Depend On Continuously Live Connections
• Database Interactions Are Performed Using Data Commands
• Data Can Be Cached in Datasets
• Datasets Are Independent of Data Sources
• Data Is Persisted as XML
• Schemas Define Data Structures
Difference between OLEDB Provider and SqlClient ?

SQLClient .NET classes are highly optimized for the .net / sqlserver combination and achieve optimal results. The SqlClient data provider is fast. It's faster than the Oracle provider, and faster than accessing database via the OleDb layer. It's faster because it accesses the native library (which automatically gives you better performance), and it was written with lots of help from the SQL Server team.
How to add a new row in DataTable?

To add a new row in DataTable, we can use NewRow() method of the DataTable object.(Here assume that there are two columns Name, Address in the DataTable.


DataTable dTable = new DataTable();
DataRow row = null;

for (int i = 0; i < 5; i++)
{
row = dTable.NewRow ();
row["Name"] = i + " - Raja";
row["Address"] = "USA";
dTable.Rows.Add(row);
}

How to create a column in the DataTable?

To create a column in the DataTable we can use the Columns.Add method of the DataTable object and pass DataColumn object as parameter.

DataTable dTable = new DataTable();

// create another column
DataColumn name = new DataColumn("Name", typeof(string));
dTable.Columns.Add(name);

How to add auto increment column in the DataTable?

To add auto increment column in the DataTable, we can set the AutoIncrement property of the DataColumn object as true and specify the seed value after adding that field into the DataTable object.


// create columns for the DataTable

DataTable dTable = new DataTable();
DataColumn auto = new DataColumn("AutoID", typeof(System.Int32));
dTable.Columns.Add(auto);
// specify it as auto increment field
auto.AutoIncrement = true;
auto.AutoIncrementSeed = 1;
auto.ReadOnly = true;

Best Method to retrieve two values from Database (SQL Server)

NOTE: This is objective type question, Please click question title for correct answer.
Which method is used to create a new row in a Table

NOTE: This is objective type question, Please click question title for correct answer.
Which method is used to commit all changes in the DataSet or DataTable?

NOTE: This is objective type question, Please click question title for correct answer.
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories