Spotify Technology Most Frequently Asked Latest ASP.NET Interview Questions Answers

Which Is The Best Place To Store Connectionstring In .net Projects ?

264 Config files are the best places to store connectionstrings. If it is a web-based application “Web.config” file will be used and if it is a windows application “App.config” files will be used.

What Are The Various Methods Provided By The Dataset Object To Generate Xml?

XML is one of the most important leap between classic ADO and ADO.NET.

 ReadXML: Read’s a XML document in to Dataset.

GetXML: This is a function which returns the string containing XML document.

WriteXML: This writes a XML data to disk.

How Can We Save All Data From Dataset ?

// create the data adapter
SqlDataAdapter dataAdapter = new
SqlDataAdapter ("SELECT userId,username FROM users ORDER BY username",
sqlConn);
// create an SqlCommandBuilder - this will automatically generate the
commands, and set the appropriate properties in the dataAdapter
SqlCommandBuilder commandBuilder = new
SqlCommandBuilder(dataAdapter);
// create the DataSet
DataSet dataSet = new DataSet();
// fill the DataSet using our DataAdapter into a table called users
dataAdapter.Fill (dataSet,"users");
// set the DataGrid source to the one table in our dataset
myDataGrid.DataSource = dataSet.Tables[0];
Then, when we've finished making our changes  to the DataSet via the DataGrid, we call

dataAdapter.Update(dataSet);
and the database will now contain the changes we have made.
Spotify Technology Most Frequently Asked Latest ASP.NET Interview Questions Answers
Spotify Technology Most Frequently Asked Latest ASP.NET Interview Questions Answers

How Can We Add/remove Row's In "datatable" Object Of "dataset" ?

 “Datatable” provides “NewRow” method to add new row to “DataTable”. “DataTable” has “DataRowCollection” object which has all rows in a “DataTable” object.

Following are the methods provided by “DataRowCollection” object :-

Add: Adds a new row in DataTable Remove It removes a “DataRow” object from “DataTable” RemoveAt: It removes a “DataRow” object from “DataTable” depending on index position of the “DataTable”.

What Is Basic Use Of "dataview" ?

“DataView” represents a complete table or can be small section of rows depending on some criteria. It is best used for sorting and finding data with in “datatable”.

Dataview has the following method’s :-

Find: It takes a array of values and returns the index of the row.

FindRow: This also takes array of values but returns a collection of “DataRow”.

If we want to manipulate data of “DataTable” object create “DataView” (Using the “DefaultView” we can create “DataView” object) of the “DataTable” object and use the following functionalities :-

AddNew: Adds a new row to the “DataView” object. Delete Deletes the specified row from “DataView” object.

How Can We Add Relation's Between Table In A Dataset ?

Dim objRelation As DataRelation objRelation=New
DataRelation ("CustomerAddresses", objDataSet.
Tables ("Customer"). Columns("Custid") ,objDataSet.
Tables("Addresses"). Columns ("Custid_fk"))
objDataSet.Relations. Add(objRelation)

 //Relations can be added between “DataTable” objects using
the “DataRelation” object.

//Above sample code is trying to build a relationship between “Customer”
and “Addresses” “Datatable” using “CustomerAddresses” “DataRelation”
object.

What Is The Use Of Commandbuilder ?

CommandBuilder builds “Parameter” objects automatically.

Below is a simple code which uses commandbuilder to load its parameter objects.

Dim pobjCommandBuilder As New OleDbCommand Builder (pobj DataAdapter)

pobjCommandBuilder.DeriveParameters(pobjCommand)
Be careful while using “DeriveParameters” method as it needs an extra trip to the Datastore which can be very inefficient

What's Difference Between "optimistic" And "pessimistic" Locking ?

In pessimistic locking when user wants to update data it locks the record and till then no one can update data. Other user’s can only view the data when there is pessimistic locking. In optimistic locking multiple users can open the same record for updating, thus increase maximum concurrency. Record is only locked when updating the record. This is the most preferred way of locking practically. Now a days browser based application is very common and having pessimistic locking is not a practical solution.

How Can We Perform Transactions In .net?

The most common sequence of steps that would be performed while developing a transactional application is as follows

Open a database connection using the Open method of the connection object.
Begin a transaction using the Begin Transaction method of the connection object.
This method provides us with a transaction object that we will use later to commit or rollback the transaction.Note that changes caused by any queries executed before calling the Begin Transaction method will be committed to the database immediately after they execute. Set the Transaction property of the command object to the above mentioned transaction object. Execute the SQL commands using the command object. We may use one or more command objects for this purpose, as long as the Transaction property of all the objects is set to a valid transaction object. Commit or roll back the transaction using the Commit or Rollback method of the transaction object. Close the database connection.

What Is Difference Between Dataset Clone And Dataset Copy ?

Dataset clone: - It only copies structure, does not copy data.

Dataset copy: - Copies both structure and data.

How Can We Force The Connection Object To Close After My Data Reader Is Closed?

Command method Execute reader takes a parameter called as Command Behavior where in we can specify saying close connection automatically after the Data reader is close.

PobjDataReader = pobjCommand.ExecuteReader
                (CommandBehavior.CloseConnection)
I Want To Force The Data Reader To Return Only Schema Of The Data Store Rather Than Data?

PobjDataReader = pobjCommand.ExecuteReader (CommandBehavior.SchemaOnly)

How Can We Fine-tune The Command Object When We Are Expecting A Single Row?

Again, CommandBehaviour enumeration provides two values Single Result and Single Row. If you are expecting a single value then pass “CommandBehaviour.SingleResult” and the query is optimized accordingly, if you are expecting single row then pass “CommandBehaviour.SingleRow” and query is optimized according to single row.

Which Is The Best Place To Store Connection String In .net Projects?

Config files are the best places to store connection strings. If it is a web-based application “Web.config” file will be used and if it is a windows application “App.config” files will be used.

How Can We Save All Data From Dataset?

Dataset has “Accept Changes” method, which commits all the changes since last time “Accept changes” has been executed.

How Can We Add/remove Row Is In "data Table" Object Of "dataset"?

“Data table” provides “NewRow” method to add new row to “Data Table”. “Data Table” has “DataRowCollection” object that has all rows in a “Data Table” object.

Following are the methods provided by “DataRowCollection” object:-

Add
Adds a new row in Data Table.

Remove
It removes a “Data Row” object from “Data Table”.

Remove At
It removes a “Data Row” object from “Data Table” depending on index position of the “Data Table”.

What Is A Linked Server?

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. 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_addlinked server, sp_addlinkedsrvlogin will be used add new Linked Server.

Post a Comment

Previous Post Next Post