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

Home Posts Topics Members FAQ

Locking a SQL Server Record from ASP + Batch Transactions

How do you lock a record in SQL Server from ASP 2? I need to read the
record, allow the user to edit it, and then have them click Save and rewrite
it. Obviously I don't want anyone else getting into this record while the
user has it up. I don't see how to have SQL Server lock this record for me
since the connection drops the moment the page is written, and would prefer
to avoid the kludge of adding and handling reservation fields to each record
if there's a better way.

Also, although I've set up batch transactions in VB6 w/o problems, I'm not
sure how to best do that in VB NET using a Sql Server Control. I'm not
sure if I have the same access to the connection that I do on VB6 ADO.

Thanks!
Sep 27 '07 #1
3 1875
What you're doing is basically a bad idea. What happens if the user locks
the record then goes away for lunch, shuts their browser down, has a power
cut etc? You should never hold locks across page processes, you'll have to
kludge it by adding a "editing by" type field or some other solution.
You're main problem is going to be issues with how long you want these
records to remain locked for.

"David C. Barber" <da***@NOSPAMdb arber.comwrote in message
news:Gs******** *************** *******@comcast .com...
How do you lock a record in SQL Server from ASP 2? I need to read the
record, allow the user to edit it, and then have them click Save and
rewrite
it. Obviously I don't want anyone else getting into this record while the
user has it up. I don't see how to have SQL Server lock this record for
me
since the connection drops the moment the page is written, and would
prefer
to avoid the kludge of adding and handling reservation fields to each
record
if there's a better way.

Also, although I've set up batch transactions in VB6 w/o problems, I'm not
sure how to best do that in VB NET using a Sql Server Control. I'm not
sure if I have the same access to the connection that I do on VB6 ADO.

Thanks!

Sep 27 '07 #2
Aidy,

Thanks for the thought, and yes that can be a hazard. So can having two
people trying to edit the same record at the same time.

I would expect that if someone locks a record and goes away for lunch, the
session terminates in 20 minutes, any connection to the SQL Server database
goes away, and the lock drops out. The problem here is that standard
database locking may not work at all since the connection actually drops the
moment the page is written, since this is a stateless system.

And btw, you solution of setting up a reservation field to kludge it has
exactly the same problem as locking the record. Someone goes away with the
reservation field set, and no one else is allowed to get to it.

"Aidy" <ai**@xxnoemail xx.comwrote in message
news:Pq******** *************** *******@bt.com. ..
What you're doing is basically a bad idea. What happens if the user locks
the record then goes away for lunch, shuts their browser down, has a power
cut etc? You should never hold locks across page processes, you'll have
to
kludge it by adding a "editing by" type field or some other solution.
You're main problem is going to be issues with how long you want these
records to remain locked for.

"David C. Barber" <da***@NOSPAMdb arber.comwrote in message
news:Gs******** *************** *******@comcast .com...
How do you lock a record in SQL Server from ASP 2? I need to read the
record, allow the user to edit it, and then have them click Save and
rewrite
it. Obviously I don't want anyone else getting into this record while
the
user has it up. I don't see how to have SQL Server lock this record for
me
since the connection drops the moment the page is written, and would
prefer
to avoid the kludge of adding and handling reservation fields to each
record
if there's a better way.

Also, although I've set up batch transactions in VB6 w/o problems, I'm
not
sure how to best do that in VB NET using a Sql Server Control. I'm not
sure if I have the same access to the connection that I do on VB6 ADO.

Thanks!



Oct 3 '07 #3
And btw, you solution of setting up a reservation field to kludge it has
exactly the same problem as locking the record. Someone goes away with
the
reservation field set, and no one else is allowed to get to it.
Yes but that is a logical problem. Such systems could tell you "This record
is locked by so-and-so and has been for 25 minutes. Do you want to override
their lock?". Whereas if you have a SQL lock people are physically
prevented from accessing the data at all until a sysadmin comes along and
starts killing processes.
Oct 3 '07 #4

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

Similar topics

12
2624
by: Alban Hertroys | last post by:
Good day, I have a number of threads doing inserts in a table, after which I want to do a select. This means that it will occur that the row that I want to select is locked (by the DB). In these cases, I believe I receive an OperationalError (or is it an InterfaceError?). Is it possible (and if so - how?) to verify that the exception occured because of row locking, so that I can wait and try again?
3
3974
by: Elliott | last post by:
I'm trying to perform this insert in a non-procedural environment: INSERT INTO table (column1, column2) SELECT :col1value, MAX(column2) + :count FROM table WHERE column1 = :col1value
12
9575
by: Puvendran | last post by:
Hi, We have encountered deadlock on a table which is used to generate sequential numbers for different categories eg typical entries Category Value TRADE_NO 1456 JOB_NO 267 .....
16
8932
by: Nid | last post by:
How do I do row-level locking on SQL Server? Thanks, Nid
1
1209
by: David McGeorge | last post by:
Dear Gurus, A Client has the following problems/requests for their Production databases, what is your professional/practical advises to tackle and resolve these issues: 1)Number of Transactions per day – The current database can currently handle about 5000 order transactions per day 2)Table locking – When doing row updates SQL Server will lock the
2
2860
by: Scott Bryce | last post by:
I am creating a CGI application in Perl that uses an Access database. It will be hosted on an NT server. I have used flat file DBMs (tied hashes) on UNIX servers, but I am not familiar with how Access behaves in a multi-user environment. Will I need to use some sort of file locking/semaphore scheme, or does Access (or the ODBC drivers?) manage conflicts between multiple users? I want to avoid corruption of data should multiple users...
13
1679
by: Jeff Davis | last post by:
Right now performance isn't a problem, but this question has me curious: Let's say I have a shopping cart system where there is a "products" table that contains all possible products, and an "cart_items" table that stores how many of each product are in each cart. The obvious (or the first thing that came to my mind) would look something like this: create table products (
9
2658
by: master | last post by:
Actually, it is not only the record locking, what I need, and nobody seems to descibe this. Imagine the following scenario. There is a database with, say 10000 records with some unvalidated data. And there is an Intranet ASP.NET application which is an interface to the database in question... and there are 100 pretty girls eager to... uhmm... use the application and validate the data of course ;-). The task is to enable the data...
0
2306
by: shakahshakah | last post by:
Just started investigating InnoDB after having used MyISAM tables in the 4.0.12 version, almost immediately ran into a locking issue with INSERTs, DELETEs, and transactions. Given the following table: CREATE TABLE test1 ( f1 varchar(32) default NULL ) and a steady stream of INSERTs from a command-line shell:
0
9666
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
9512
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10419
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
9987
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6770
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5424
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3709
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2910
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.