Search!!

Loading...

Followers

Dec 17, 2010

ADO.NET Interview Questions Answers:Part 2

ADO.NET Interview Questions and Answers,Common ADO .Net Interview Questions and most frequently asked ADO .Net Interview Questions during Interviews

Give Expansions of ODBC,OLE,OLE DB,ADO?
1.ODBC-Open Database Connectivity.
2.OLE-Object Linking and Embedding.
3.OLE DB-Object Linking and Embedding for Database.
4.ADO-ActiveX Data Object.

How to convert a DataSet to a DataReader?
DataTableReader rd = ds.Tables[0].CreateDataReader();

What is a DataSet?
The Dataset is the central object in ADO.NET. DataSet is a logical container of data. It represents a set of data tables referenced as one unit in the application.

With this object you can get all the data you need from each table quickly, examine and change it while you are disconnected from the server and then update the server with changes in an efficient operation.

How to fill DataSet with data?
To fill DataSet with data we have to use Fill() method of DataAdapter object.
Fill() has several overloads. But the simple one is
Fill(DataSet, DataTable)


The first parameter will take the name of the dataset to be filled and the second parameter specifies the name of the DataTable in the DataSet which will contain the data.

What is the use of DataSet?
DataSet acts as a virtual table. The value is retrieved from the database
and stores in the DataSet. Then we can pass the data to the DataGrid through DataSet.

What are the benefits of ADO.NET?
BENEFITS OF ADO.NET


1.Scalability:-
ADO.NET works on DataSet that can represent a whole database or even a data table as a disconnected object and thereby eliminates the problem of the constraints of number of databases being connected. In this way scalability is achieved.

2.Data Source Independence:-
In ADO.NET DataSet is completely independent of data source and no way DataSet is controlled by the data source as it happens in case of RecordSet.

3.Interoperability:-
As ADO.NET transmits the data using the format of XML which is not dependent on ADO.NET or windows platform.

4.Strongly Typed Fields:-
It supports strongly typed fields by using CTS.

5.Performance:-
The performance in ADO.NET is higher in comparison to ADO that uses COM marshalling.

6.Firewall:
As in ADO.NET transmission is via XML format, therefore it can pass through firewalls.

What are the components of .NET DataProvider?
The .NET DataProvider is a set of components that includes the Connection, Command, DataReader and DataAdapter objects. It is used for connecting to a database , executing commands and retrieving results. Using the .NET data provider we can either access database directly or use the disconnected approach. For the disconnected approach we use DataSet class.

Connection Object:- It is used to connect to the data source. Data source can be any database file. The connection object contains information like the provider name, server name, datasource name, user name and password.

Command Object:- It is used for connect the connection object to a DataReader or DataAdapter object. The command object allow us to execute SQL statement or a stored procedure in a data source.


DataReader Object:- It is used to read the data in a fast and efficient manner from the database. It is generally used to extract one or a few records or specific field values or to execute simple SQL statement.

DataAdapter Object:- It is used to fill data from the database into the DataSet object. it is use din the disconnected approach.

What are the differences between ADO and ADO.NET?
ADO relied on a connection based model . In the connected approach, the client had to be connected with the server and remain connected till the whole procedure or transaction was completed. Time resources and bandwidth became major constraints on such architecture.

To solve this problem the latter version of ADO used RecordSet. All the contents from the data source were copied into RecordSet. This allows clients to get disconnected from the server, work on the RecordSet and copy the changes back to the data source again. This approach did not succeed much because it requires COM marshalling to transmit disconnected data, it support only those datatypes that were defined by the COM standards and hence required type conversion.

ADO.NET can be used to access data sources using new .NET data providers as well as existing OLEDB data providers using the OLEDB.NET data provider.

How can you update the records in database using datareader?
Well, You cannot update. DataReader is just used for reading the data in forward only mode. You can achieve this using Dataset but not by DataReader.

What is Dataview in ADO Dot Net ?
The DataView provides different views of the data stored in a DataTable. That is we can customize the views of data from a DataTable. DataView can be used to sort, filter, and search the data in a DataTable , additionally we can add new rows and modify the content in a DataTable.

We can create DataView in two ways. Either we can use the DataView constructor, or we can create a reference to the DefaultView property of the DataTable.

DataView dView = new DataView(dTbl);
dView = dataSet.Tables(0).DefaultView;

Stored procedure return more than one resut set and datareader used to fetch record, how you fetch second result set using datareader?
Posted by: Bprasad
Use DataReader.NextResult()

True - It Check more result remain to read and reader will forward to next result.
False - No more result set found

Name the classes that are contained in System.Data NameSpace?
DataSet
DataTable
DataColumn
DataRow
DataRealation
Constraint

No comments:

Post a Comment

 

Aired : Interview Questions | Certifications | Tutorials | Career Help | Copyright © 2009-2013