How do u implement locking concept for dataset?
Answer Posted / akash
One way to work around optimistic concurrency issues in ADO
is to lock the records your DataSet retrieves as soon as
the edit operation begins. This strategy is known as
pessimistic locking. Long-duration locks generally lead to
poor database performance and contention problems, but in
situations where an application cannot tolerate having
records changed while it is updating them, pessimistic
locking may be necessary.
With ADO, it's relatively easy to use a pessimistic locking
scheme. In ADO.NET, it's somewhat more difficult to set up,
but you can still use pessimistic locking in your
applications. However, just because you can do something
doesn’t mean you should do it all the time—what I’m about
to explain should be used only when absolutely necessary.
The basics steps for pessimistic locking are as follows:
1)Create a transaction with an IsolationLevel of
RepeatableRead.
2)Set the DataAdapter’s SelectCommand property to use the
transaction you created.
3)Make the changes to the data.
4)Set DataAdapter’s Insert, Update, and Delete command
properties to use the transaction you created.
5)Call the DataAdapter’s Update method.
6)Commit the transaction.
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
Explain the role of data provider in ado.net?
Which property is used to check whether a DataReader is closed or opened?
What is the difference between sqldatareader and sqldataadapter?
Do we use stored procedure in ADO.Net?
What is difference between dataset and datatable?
What is sql command in ado net?
Explain the advantages and disadvantages of using datalist?
How to copy the contents from one table to another table and how to delete the source table in ado.net?
What are the pre-requisites for connection pooling?
Explian About DataAdapters
What are the 3 major types of connection objects in ado.net?
Give few examples of datareader that is used in different dataproviders.
What is bubbled event can you please explain?
oledbdataadpter with ms access in c#.net giving exception System.Data.OleDb.OleDbException while writing adapter.update(dataset,"tabname"); how to update the database from dataset?
What is microsoft ole db provider for sql server?