Showing posts with label ado.net training. Show all posts
Showing posts with label ado.net training. Show all posts

Friday, March 16, 2012

ADO.NET interview questions: - Mention different ways to implement optimistic locking in ADO.NET?

Following are the ways to implement optimistic locking using ADO.NET:-
  • When we call “Update” method of Data Adapter it handles locking internally. If the Dataset values are not matching with current data in Database, it raises concurrency exception error. We can easily trap this error using Try. Catch block and raise appropriate error message to the user.

  • Define a Date time stamp field in the table. When actually you are firing the UPDATE SQL statements, compare the current timestamp with one existing in the database. Below is a sample SQL which checks for timestamp before updating and any mismatch in timestamp it will not update the records. This I the best practice used by industries for locking.
Update table1 set field1=@test where Last Timestamp=@Current Timestamp
  • Check for original values stored in SQL SERVER and actual changed values. In stored procedure check before updating that the old data is same as the current Example in the below shown SQL before updating field1 we check that is the old field1 value same. If not then some one else has updated and necessary action has to be taken.
Update table1 set field1=@test where field1 = @oldfield1value
Locking can be handled at ADO.NET side or at SQL SERVER side i.e. in stored procedures.
See the following video on SQL Server which describes difference between UNION and UNION All: -


Learn more on ADO.NET interview questions
Regards,
From more on author’s blog related to ADO.NET interview questions click and visit.

Tuesday, November 29, 2011

ADO.NET interview questions: - Elaborate different implementing ways of optimistic locking in ADO.NET.

This is one of the ADO.NET interview questions asked in the interview. Answer this question with the simple steps as follows.

Ways to implement optimistic locking using ADO.NET: -
  • When we call “Update” method of Data Adapter it handles locking internally. If the Dataset values are not matching with current data in Database, it raises concurrency exception error. We can easily trap this error using Try. Catch block and raise appropriate error message to the user.
  • Define a Date time stamp field in the table. When actually you are firing the UPDATE SQL statements, compare the current timestamp with one existing in the database. Below is a sample SQL which checks for timestamp before updating and any mismatch in timestamp it will not update the records. This I the best practice used by industries for locking.
Update table1 set field1=@test where Last Timestamp=@Current Timestamp
  • Check for original values stored in SQL SERVER and actual changed values. In stored procedure check before updating that the old data is same as the current Example in the below shown SQL before updating field1 we check that is the old field1 value same. If not then some one else has updated and necessary action has to be taken.
Update table1 set field1=@test where field1 = @oldfield1value

Locking can be handled at ADO.NET side or at SQL SERVER side i.e. in stored procedures: -

Also see the following video on Table Scan And Unique key in SQL Server: -



Please click here to see more ADO.NET interview questions

Regards,

Visit Authors blog for more ADO.NET interview questions

Thursday, November 10, 2011

ADO.NET interview questions: - What are the namespaces provided by .NET for data management?


Following are the namespaces provided by .NET for data management:-
System.Data

This namespace has the dataset object which helps us to access data in a data source independent manner.
System.Data.SqlClient:

This namespace has objects which helps us to connect to SQL Server database.
System.Data.OleDB

This namespace has objects which helps us to connect to other databases like Oracle, Access and also SQL Server database.
System.XML

This Contains the basic objects required to create, read, store, write, and manipulate XML documents.














ADO.NET namespaces

See the following video on calling a stored procedure using LINQ: -













Avail from the link more ADO.NET interview questions for preparation.

Regards,

Refer author’s other blog for complete ADO.NET interview questions

Tuesday, November 8, 2011

ADO.NET interview questions: - Different components in ADO.NET.

There are 6 important components in ADO.NET:-
  • Connection: -This object creates a connection to the database. If you want to do any operation on the database you have to first create a connection object.
  • Command: -This object helps us to execute SQL queries against database. Using command object we can execute select, insert, update and delete SQL command.
  • Data reader: - This provides a recordset which can be browsed only in forward direction. It can only be read but not updated. Data reader is good for large number of records where you want to just browse quickly and display it.
  • Dataset object: -This provides a recordset which can be read back and in forward direction. The recordset can also be updated. Dataset is like a in memory database with tables, rows and fields.
  • Data Adapter: -This object acts as a bridge between database and dataset; it helps to load the dataset object.
  • Data View: - This object is used to sort and filter data in Data table of dataset.


                                                     Figure: - ADO.NET architecture

See the following video on Table Scan and Unique key in SQL Server: -



Get more on ADO.NET interview questions

Regards,

For more on ADO.NET interview questions from author’s blog.

Tuesday, October 25, 2011

ADO.NET interview questions: - What are the ways to implement optimistic locking in ADO.NET?

An interesting ADO.NET interview questions mostly asked by the interviewer during an interview. Following are the ways to implement optimistic locking using ADO.NET: -

  • When we call “Update” method of Data Adapter it handles locking internally. If the Dataset values are not matching with current data in Database, it raises concurrency exception error. We can easily trap this error using Try. Catch block and raise appropriate error message to the user.
     
  • Define a Date time stamp field in the table. When actually you are firing the UPDATE SQL statements, compare the current timestamp with one existing in the database. Below is a sample SQL which checks for timestamp before updating and any mismatch in timestamp it will not update the records. This I the best practice used by industries for locking.
   Update table1 set field1=@test where Last Timestamp=@Current Timestamp
  • Check for original values stored in SQL SERVER and actual changed values. In stored procedure check before updating that the old data is same as the current Example in the below shown SQL before updating field1 we check that is the old field1 value same. If not then some one else has updated and necessary action has to be taken.
Update table1 set field1=@test where field1 = @oldfield1value




Locking can be handled at ADO.NET side or at SQL SERVER side i.e. in stored procedures.

 Know more on UML’s object diagram by viewing the following video: -



For more on ADO.NET interview questions, so click and visit.

Regards,

Author’s more on ADO.NET interview questions.

Tuesday, September 6, 2011

ADO.NET interview questions: - Can you explain connection, command, datareader and dataset in ADO.NET?

• Connection: - This object creates a connection to the database. If you
want to do any operation on the database you have to first create a connection
object.

• Command: - This object helps us to execute SQL queries against
database. Using command object we can execute select, insert, update and delete
SQL command.

• Data reader: - This provides a recordset which can be browsed only in
forward direction. It can only be read but not updated. Data reader is good for
large number of records where you want to just browse quickly and display it.

• Dataset object: - This provides a recordset which can be read back and
in forward direction. The recordset can also be updated. Dataset is like a in
memory database with tables, rows and fields.

• Data Adapter: - This object acts as a bridge between database and
dataset; it helps to load the dataset object.

Know more on calling a stored procedure using LINQ by viewing the following
video: -



Get more ADO.NET interview questions for preparation.

Regards,

Visit author’s other blogs on ADO.NET interview questions

Tuesday, July 12, 2011

C# and ADO.NET interview questions :- What is the difference between Dataset.clone() and Dataset.copy()?

The answer is the easy , people just get confused by the word clone and copy as they almost mean same things.
Dataset.clone(): The clone function only copies the structure of the dataset, including all schemas, relations, and constraints but it does not copy data.

Dataset.copy(): The copy function copies both the structure and data.

Following is the SQL server interview questions which shows difference between unique key and primary key.




Please click here to see more C# and ADO.NET Interview questions

Regards,


Visit Authors blog for more C# and ADO.NET Interview questions

Wednesday, May 25, 2011

SQL and .NET interview Question - Why ADO.NET is better from ADO?

Answer:

The ADO.NET is better from ADO by the below reasons-




You will be also interested in watching the below video, which are also asked in most of the interviews and favorable question of interviewers.


Please click here to see more SQL/.NET interview questions

Regards,

Visit Authors blog for more .SQL/.NET interview questions

Tuesday, March 8, 2011

C# interview questions :- In ADO.NET What is connection, command, datareader and dataset object ?

Answer:
Connection: - This object creates a connection to the database. If you want to do any operation on the database you have to first create a connection object.
Command: - This object helps us to execute SQL queries against database. Using command object we can execute select, insert, update and delete SQL command.
Data reader: - This provides a recordset which can be browsed only in forward direction. It can only be read but not updated. Data reader is goodfor large number of records where you want to just browse quickly and display it.
Dataset object: - This provides a recordset which can be read back and in forward direction. The recordset can also be updated. Dataset is like a in memory database with tables, rows and fields.
Data Adapter: - This object acts as a bridge between database and dataset; it helps to load the dataset object.
See my 21 important .NET interview question and answers

Monday, December 13, 2010

37 important interview questions on ADO.NET

37 important interview questions on
ADO.NET


This section will cover the most asked questions related to ADO.NET during .net interview by the interviewer so have a look on the following and do revise it when ever you go for the ADO.NET interview
Normally the .net interviewer starts with.....

What is the namespace in which .NET has the data functionality class?
Can you give an overview of ADO.NET architecture?
What are the two fundamental objects in ADO.NET?
What is difference between dataset and data reader?
What are major difference between classic ADO and ADO.NET?
What is the use of connection object?
What is the use of command objects?
What is the use of data adapter?
What are basic methods of Data adapter?
What is Dataset object?
What are the various objects in Dataset?
How can we connect to Microsoft Access, FoxPro, and Oracle etc?
How do we connect to SQL SERVER, which namespace do we use?
How do we use stored procedure in ADO.NET and How do we provide parameters
to the stored procedures?

How can we force the connection object to close after my data reader is
closed?

I want to force the data reader to return only schema of the data store
rather than data.

How can we fine-tune the command object whe we are expecting a single
row?

Which is the best place to store connection string in .NET projects?
What are the steps involved to fill a dataset?
What are the various methods provided by the dataset object to generate
XML?

How can we save all data from dataset?
How can we check that some changes have been made to dataset since it was
loaded?

How can we add/remove row is in “Data Table” object of “Dataset”?
What is basic use of “Data View”?
What is the difference between “Dataset” and “Data Reader”?
How can we load multiple tables in a Dataset?
How can we add relation between tables in a Dataset?
What is the use of Command Builder?
What’s difference between “Optimistic” and “Pessimistic” locking?
How many ways are there to implement locking in ADO.NET?
How can we perform transactions in .NET?
What is difference between Dataset Clone and Dataset. Copy?
Can you explain the difference between an ADO.NET Dataset and an ADO
Record set?

Explain in detail the fundamental of connection pooling?
What is Maximum Pool Size in ADO.NET Connection String?
How to enable and disable connection pooling?
What extra features does ADO.Net 2.0 have?
So friends answering to above questions on ADO.NET helped me to clear interview in
front of the interviewer.