473,505 Members | 13,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Possible to toggle Updatable<->Read-Only record

Hi,

I'm having an issue in my C#.NET desktop application where two or more
people viewing/editing the same record (from SQL Server) keep overwriting
each others changes.

Is there a setting in SQL Server (or some other easy way) to make it so that
only the first user may update the record and any subsequent users get a
"read-only" version of the record, similar to how it works with Microsoft
Office word and excel documents?

What I was thinking was programming the "Save" button to add a JobInUse=1,
JobID=Some Job ID to the database and then have all users read that table to
see if they can edit the record, however some times people do not close their
programs/computers down properly... If that happened, the record would never
get updated with JobInUse=0 to show they are done working with it so I fear
this solution may not work.

Does anyone have any good solutions for this? Please help and thanks in
advance!

R
Jul 24 '08 #1
1 1543
One potential solution to this is to have a version number column of every
table. When you select a record, select the version, when you update a
record, check that the version number is the same as the one you selected
before updating. The only other way to do this is to record that the row is
in use by somebody and the datetime they last accessed it. Then you can time
people out after 10 minutes or so to update the record, or if they login
again (because their app/machine crashed), you could remove their lock. If
the app has the screen open for a long period of time, meaning longer than
your time out, you could have the application upate the last accessed time to
prevent other users thinking they have timed out. It produces more hits to
the db but they should be small and required to get the task done.

It depends on whether you want to make people aware when they open a record
that it is being edited by someone else, or just tell them when they save it.

The only way to make this more secure is to have a piece of middle ware
somewhere track the records in use. Then when a session to the middleware
closes, release all the records marked in use by that user.
--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"R Reyes" wrote:
Hi,

I'm having an issue in my C#.NET desktop application where two or more
people viewing/editing the same record (from SQL Server) keep overwriting
each others changes.

Is there a setting in SQL Server (or some other easy way) to make it so that
only the first user may update the record and any subsequent users get a
"read-only" version of the record, similar to how it works with Microsoft
Office word and excel documents?

What I was thinking was programming the "Save" button to add a JobInUse=1,
JobID=Some Job ID to the database and then have all users read that table to
see if they can edit the record, however some times people do not close their
programs/computers down properly... If that happened, the record would never
get updated with JobInUse=0 to show they are done working with it so I fear
this solution may not work.

Does anyone have any good solutions for this? Please help and thanks in
advance!

R

Aug 7 '08 #2

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

Similar topics

8
2006
by: Derek Fountain | last post by:
I'm having trouble understanding the use of XSLT variables. I'm trying to add up the values from a set of elements. The code currently looks like this: <xsl:variable name="orderTotal">...
16
2062
by: Michael | last post by:
just a quickie: as cout << endl; is to cout << "\n"; is there an equivalent for cout << "\t";
3
1233
by: Gaijinco | last post by:
If I have this: struct node{ int data; node *left, *right; }; It's possible to in-code say something like:
30
4596
by: mistral | last post by:
Neeed good javascript unescape encoder, to protect javascript code. Some advices? Online tool, or ready javascript only. Any opinions about the Javascript Obfuscator:...
10
5612
by: Jim Langston | last post by:
Is the following well defined? size_t IntVal = 65537; unsigned short Length; if ( IntVal static_cast<unsigned short>( -1 ) ) { std::cout << "Value too long to fit in a short" << std::endl;...
5
1268
by: teddysnips | last post by:
In the class declaration of a web service that I've just picked up for maintenance: <Obsolete("Superseded by OrderPaymentElements")Public PaymentType As OrderPaymentType Public...
137
6573
by: mathieu.dutour | last post by:
Dear all, I want to do multiprecision floating point, i.e. I want to go beyond single precision, double precision and have quadruple precision, octuple precision and the like, and possibly with...
0
7213
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,...
0
7298
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,...
0
7366
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...
0
7471
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...
0
5610
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,...
0
3187
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...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
406
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...

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.