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

what is function import in entity framework ?

Adding a stored procedure to a conceptual model is known as function important.
It can return collections of simple types,entity types or complex types or return no value.
What is the use of connection object in ado.net ?

The Connection Object in ADO is used to create an open connection to a data source. Through this connection, you can access and manipulate a database.
What is the 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 faster than the Oracle provider, and faster than accessing database via the OleDb layer.
What is the use of Parameter Object ?

In ADO.NET, the Parameter object provides information about a single parameter used in a stored procedure or query.
What is Data Provider ?

Data Provider is nothing but a set of libraries that is used to communicate with data source.
Eg: SQL data provider for SQL, Oracle data provider for Oracle, OLE DB data provider for access, excel or mysql.
what is data access layer ?

Data Access layer is a part of Architecture layer.
This Architecture layer has 2 tier,3 tier or N tier Layer.
Generally we use 3 tier Layer.
1) Presentation layer,Business Logic layer and then Data Access Layer.
Data Access layer is a medium to talk between database and Business Logic layer. It helps to maintain flexibility,reusability and even security also. In security SQL Injection can be stopped with 3 tier Architecture.
What are the major differences between classic ADO and ADO.NET?

Following are some of the major differences between both

1) In ADO we have record set and in ADO.NET we have dataset.
2) In recordset we can only have one table. If we want to accommodate more than one table. We need to do inner join and fill the recordset. Dataset can have multiple tables.
3) All data persist in XML as compared to classic ADO where data persisted in Binary format also.
Explain the DataAdapter.Update() and DataSetAcceptChanges() methods.

The DataAdapter.Update() method calls any of the DML statements, such as the UPDATE, INSERT, or DELETE statements, as the case may be to update, insert, or delete a row in a DataSet.

Example:

Dim NumberOfRowsUpdated As Integer 

NumberOfRowsUpdated = MyDataAdapter.Update(MyDataSet, "MyCustomer")



The DataSet.Acceptchanges() method reflects all the changes made to the row since the last time the AcceptChanges() method was called.

Example:

Private Sub AcceptChanges()

Dim myDataSet As DataSet
myDataSet = new DataSet()

' Not shown: methods to fill the DataSet with data.
Dim t As DataTable

t = myDataSet.Tables("Suppliers")

' Add a DataRow to a table.
Dim myRow As DataRow
myRow = t.NewRow()
myRow("CompanyID") = "NWTRADECO"
myRow("CompanyName") = "NortWest Trade Company"

' Add the row.
t.Rows.Add( myRow )

' Calling AcceptChanges on the DataSet causes AcceptChanges to be
' called on all subordinate objects.
myDataSet.AcceptChanges()
End Sub

How can you identify whether or not any changes are made to the DataSet object since it was last loaded ?

The DataSet object provides the following two methods to track down the changes:

1) GetChanges() method - Returns the DataSet object, which is changed since it was loaded or since the AcceptChanges() method was executed.

2) HasChanges() method - Indicates if any changes occurred since the DataSet object was loaded or after a call to the AcceptChanges() method was made.

If you want to revert all changes since the DataSet object was loaded, use the RejectChanges() method.
Which property is used to check whether a DataReader is closed or opened ?

The property which is used to check whether a DataReader is closed or opened is by using IsClosed property.
This property returns a true value if a Data Reader is closed, otherwise a false value is returned.
What is the use of the Connection object ?

By providing the required authentication information in connection string, the Connection object is used to connect your application to a specific data source. The connection object is used according to the type of the data source.
For example, the OleDbConnection object is used with an OLE-DB provider and the SqlConnection object is used with an MS SQL Server.
What is the use of the CommandBuilder class ?

The CommandBuilder class is used to automatically update a database according to the changes made in a DataSet.

This class automatically registers itself as an event listener to the RowUpdating event. Whenever data inside a row changes, the object of the CommandBuilder class automatically generates a SQL statement and uses the SelectCommand property to commit the changes made in DataSet.

For Example, OLEDB provider in .NET Framework has the OleDbCommandBuiider class; whereas, the SQL provider has the SqlCommandBuilder class.
Describe the disconnected architecture of ADO.NET's data access model.

ADO.NET maintains a disconnected database access model.
This disconnected database access model means, the application never remains connected constantly to the data source. Any changes and operations done on the data are saved in a local copy (dataset) that acts as a data source. Whenever, the connection to the server is re-established, these changes are sent back to the server, in which these changes are saved in the actual database or data source.
What is the transport protocol you use to call a Web service SOAP ?

Web service uses only three types of protocol.
They are:

1) HTTP-GET
2) HTTP-POST
3) SOAP.
Can a .NET web application consume Java web service ?

Yes Off course.
Actually Web services are independent of languages.
It depends on WSDL and SOAP. So any one can develop the Web services and disclose the wsdl and users can consume the web services.wsdl and soap both are xml based.
All languages having xml parsing capability and access to http protocol will be able to work with Web services.
How do you create a permanent cookie ?

Setting a permanent cookie is similar to Session cookie, except giving the cookie an expiration date. It is very common that you don't specify any arbitrary expiration date, but instead expire the cookie relative to the current date, using the DateAdd() function.

Response.Cookies("Name") = "myCookie" 

Response.Cookies("Name").Expires = DateAdd("m", 1, Now())

How to find the given query is optimised one or not ?

First, Execute Sql Queries in Query Analyzer. Check How much time it takes to execute the queries.
If it takes less than your desired time, then it is as Optimize query.
How to find the count of records in a dataset ?

By using the below Code, we get the count of records in a Dataset.

DS.Tables["tabname"].Rows.Count;

How would you get ASP.NET running in Apache web servers - why would you even do this ?

To run the ASP.NET applications within the Apache (http://httpd.apache.org) web server, the module called mod_mono Apache module is used
Mod_mono is available from (http://www.mono-project.com/Downloads).
XSP is a standalone web server written in C# that can be used to run your ASP.NET applications. XSP works under both the Mono and Microsoft run times.
How to identify the updated rows in a dataset ?

If the RowState property of the DataRow is "Modified" then that DataRow can be treated as updated.

If dr.RowState=DataRowState.Modified then

' u r logic here
End if

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