473,791 Members | 3,360 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Lock record

HDI
Hi,
I'm writing a windows application where users can update records but
how can I lock a record when a user opens it.

With ado and vb6 you can lock the opened record but with ado.net I
don't know how to do this.

I am using vb.net and SQL Server.
thx.

Jan 18 '07 #1
3 2540
I agree, I've seen cases where a record was locked when it was opened. The
person going out to lunch, leaving it locked and others who needed access to
it being unable to get it until he/she came back and released the lock.
Not a good idea unless you realy think through and handle all the
unexpected problem scenarios, which is a lot of work.

Regards,
Bob
"Kerry Moorman" <Ke**********@d iscussions.micr osoft.comwrote in message
news:EC******** *************** ***********@mic rosoft.com...
HDI,

The disconnected architecture of ado.net encourages optimistic locking to
deal with concurrency issues. This is the approach used by most of the
ado.net code that I have encountered.

You can still make pessimistic locking work, but unless you have a really,
really good reason to do so, you should first consider using optimistic
locking.

Kerry Moorman
"HDI" wrote:
>Hi,
I'm writing a windows application where users can update records but
how can I lock a record when a user opens it.

With ado and vb6 you can lock the opened record but with ado.net I
don't know how to do this.

I am using vb.net and SQL Server.
thx.


Jan 19 '07 #2
HDI
What are the pro's and contra's of optimistic and pessimistic logging?
Robert Dufour schreef:
I agree, I've seen cases where a record was locked when it was opened. The
person going out to lunch, leaving it locked and others who needed access to
it being unable to get it until he/she came back and released the lock.
Not a good idea unless you realy think through and handle all the
unexpected problem scenarios, which is a lot of work.

Regards,
Bob
"Kerry Moorman" <Ke**********@d iscussions.micr osoft.comwrote in message
news:EC******** *************** ***********@mic rosoft.com...
HDI,

The disconnected architecture of ado.net encourages optimistic locking to
deal with concurrency issues. This is the approach used by most of the
ado.net code that I have encountered.

You can still make pessimistic locking work, but unless you have a really,
really good reason to do so, you should first consider using optimistic
locking.

Kerry Moorman
"HDI" wrote:
Hi,
I'm writing a windows application where users can update records but
how can I lock a record when a user opens it.

With ado and vb6 you can lock the opened record but with ado.net I
don't know how to do this.

I am using vb.net and SQL Server.
thx.

Jan 19 '07 #3
HDI
What are the pro's and contra's of optimistic and pessimistic locking?
Robert Dufour schreef:
I agree, I've seen cases where a record was locked when it was opened. The
person going out to lunch, leaving it locked and others who needed access to
it being unable to get it until he/she came back and released the lock.
Not a good idea unless you realy think through and handle all the
unexpected problem scenarios, which is a lot of work.

Regards,
Bob
"Kerry Moorman" <Ke**********@d iscussions.micr osoft.comwrote in message
news:EC******** *************** ***********@mic rosoft.com...
HDI,

The disconnected architecture of ado.net encourages optimistic locking to
deal with concurrency issues. This is the approach used by most of the
ado.net code that I have encountered.

You can still make pessimistic locking work, but unless you have a really,
really good reason to do so, you should first consider using optimistic
locking.

Kerry Moorman
"HDI" wrote:
Hi,
I'm writing a windows application where users can update records but
how can I lock a record when a user opens it.

With ado and vb6 you can lock the opened record but with ado.net I
don't know how to do this.

I am using vb.net and SQL Server.
thx.

Jan 19 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3602
by: xixi | last post by:
hi, we are using db2 udb v8.1 ESE with type 4 jcc driver. since DB2 can't support pessimistic locking , and our application required that, which means when both users try to access the same record with intent to update, the first one grab the record will create a row lock on the current row reading, before it update, other user can't access the same record with intent for update read, but can access with read only type. so when the first...
0
2529
by: Andrew Cutforth | last post by:
I have a strange problem that I have not come across before. In a multi user situation I have a readonly query open. When another user tries to post a change to that record it says it is locked. How can a readonly query cause Access to lock the record ? I am not even trying to edit the record. If I move to another record or close the query, the lock goes away and the other user can post the changes.
14
3839
by: Gary Nelson | last post by:
Anyone have any idea why this code does not work? FileOpen(1, "c:\JUNK\MYTEST.TXT", OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Shared) Dim X As Integer For X = 1 To 26 FilePut(1, Chr(X + 64)) Next Lock(1, 5, 10)
4
4093
by: Ed L. | last post by:
I think I'm seeing table-level lock contention in the following function when I have many different concurrent callers, each with mutually distinct values for $1. Is there a way to reimplement this function using select-for-update (or equivalent) in order to get a row-level lock (and thus less contention) while maintaining the function interface? The docs seem to suggest so, but it's not clear how to return the SETOF queued_item and also...
8
4014
by: Komandur Kannan | last post by:
We have a smart device application running on handhelds(Symbol MC9000G). The backend is Oracle and a middle tier web services development done in Vb.net. We use pessimistic Locking due to specific business needs When such a lock is made for a transaction (this code is in the web service) and the handhelds are terminated abnormally (cold booted or battery low), the lock still remains. The Web service's connection to oracle is still...
2
15802
by: adri4n | last post by:
as wat ive mentioned in the title.. im would like to know whether the a particular record/table is being locked in my program. some of the methods which i would like to develop are as below: Lock(KEY, SQLCODE) - to create a lock. Returns 0 on success, 1 if a lock already exists and -1 on failure with SQLCODE. There is no necessity to use IsLock() for checking if a lock exists or not, just insert the record and check for
2
5867
by: shenanwei | last post by:
DB2 V8.2 on AIX, type II index is created. I see this from deadlock event monitor. 5) Deadlocked Connection ... Participant no.: 2 Lock wait start time: 09/18/2006 23:04:09.911774 ...... Deadlocked Statement: Type : Dynamic Operation: Execute
8
1320
by: Ritesh Raj Sarraf | last post by:
Hi, I think there is some lock problem. Let me show the code first import os import sys import string import tempfile
5
8830
by: payffl | last post by:
My users are running Access '03. They have a database with a form that allows them to enter new records. Frequently they will move to a new record and not enter any information. This prevents the record from writing to the table, and worse, it prevents anyone else from opening the database (db has been placed in a state by user....etc.) I haven't been able to figure a way to force the autonumber to generate with an event on the new...
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10428
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10156
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9030
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.