Visual Studio 2003 .Net / C# / SQL 2000
I am trying to work out the best way to ensure data concurrency in my
application. All updates and inserts etc are done via stored procedures.
When a user enters a screen i call a stored procedure which returns me a
record or many records and display them in my screen. When they insert a
record I just call a stored procedure passing over all the screen values, and
the same with updating records. At the moment I have not done anything to do
with concurrancy in the application so I am open to all ideas. One idea I
have had is that each table has a "Version" field, and that everytime I
display the data you retrieve the version number, then when you update a
record you check this version number is still the same in the db, if it is
then you commit, if its not then you error as someone else must have updated
that record. But where would this code go? do I put this in each stored
proc or do I have a generic stored proc for it or to I code it into the
screen?
Thanks
Steve 5 1485
Your idea of a "version" is a good one, but you don't need to create this,
you should already have a primary key field in your database and that field
is what you should be checking your new data against. It's not so much a
version of the existing data as it is making sure that you are working on
the correct record. The primary key ensures this.
In your sp's, you should be adding a WHERE condition that checks the primary
key of the record being edited against a primary key in the database to
ensure that the correct record gets modified.
"Steve" <St***@discussi ons.microsoft.c om> wrote in message
news:8A******** *************** ***********@mic rosoft.com... Visual Studio 2003 .Net / C# / SQL 2000
I am trying to work out the best way to ensure data concurrency in my application. All updates and inserts etc are done via stored procedures. When a user enters a screen i call a stored procedure which returns me a record or many records and display them in my screen. When they insert a record I just call a stored procedure passing over all the screen values, and the same with updating records. At the moment I have not done anything to do with concurrancy in the application so I am open to all ideas. One idea I have had is that each table has a "Version" field, and that everytime I display the data you retrieve the version number, then when you update a record you check this version number is still the same in the db, if it is then you commit, if its not then you error as someone else must have updated that record. But where would this code go? do I put this in each stored proc or do I have a generic stored proc for it or to I code it into the screen?
Thanks
Steve
I do already have a where in there to ensure i am updating the correct
record, the main issue I am trying to address though here is different. If a
user for example, brings a record up to view, then go and make a drink or
something so is away from their desk for a couple of minutes. Then another
user logs on, brings up that same record and changes it before user 1 comes
back. Then, user1 comes back and changes the record, theres a problem,
because the version of the data that he/she is looking at is now incorrect as
someone else changed that same record.
"Scott M." wrote: Your idea of a "version" is a good one, but you don't need to create this, you should already have a primary key field in your database and that field is what you should be checking your new data against. It's not so much a version of the existing data as it is making sure that you are working on the correct record. The primary key ensures this.
In your sp's, you should be adding a WHERE condition that checks the primary key of the record being edited against a primary key in the database to ensure that the correct record gets modified. "Steve" <St***@discussi ons.microsoft.c om> wrote in message news:8A******** *************** ***********@mic rosoft.com... Visual Studio 2003 .Net / C# / SQL 2000
I am trying to work out the best way to ensure data concurrency in my application. All updates and inserts etc are done via stored procedures. When a user enters a screen i call a stored procedure which returns me a record or many records and display them in my screen. When they insert a record I just call a stored procedure passing over all the screen values, and the same with updating records. At the moment I have not done anything to do with concurrancy in the application so I am open to all ideas. One idea I have had is that each table has a "Version" field, and that everytime I display the data you retrieve the version number, then when you update a record you check this version number is still the same in the db, if it is then you commit, if its not then you error as someone else must have updated that record. But where would this code go? do I put this in each stored proc or do I have a generic stored proc for it or to I code it into the screen?
Thanks
Steve
No, the issue isn't different. Most "good" primary keys are made up of
values that are a combination of some unique data-specific value and a
timestamp. When used this way, the timestamp piece can be checked to see if
you are working with the same record "version" as is in the database.
"Steve" <St***@discussi ons.microsoft.c om> wrote in message
news:62******** *************** ***********@mic rosoft.com... I do already have a where in there to ensure i am updating the correct record, the main issue I am trying to address though here is different. If a user for example, brings a record up to view, then go and make a drink or something so is away from their desk for a couple of minutes. Then another user logs on, brings up that same record and changes it before user 1 comes back. Then, user1 comes back and changes the record, theres a problem, because the version of the data that he/she is looking at is now incorrect as someone else changed that same record.
"Scott M." wrote:
Your idea of a "version" is a good one, but you don't need to create this, you should already have a primary key field in your database and that field is what you should be checking your new data against. It's not so much a version of the existing data as it is making sure that you are working on the correct record. The primary key ensures this.
In your sp's, you should be adding a WHERE condition that checks the primary key of the record being edited against a primary key in the database to ensure that the correct record gets modified. "Steve" <St***@discussi ons.microsoft.c om> wrote in message news:8A******** *************** ***********@mic rosoft.com... > Visual Studio 2003 .Net / C# / SQL 2000 > > I am trying to work out the best way to ensure data concurrency in my > application. All updates and inserts etc are done via stored > procedures. > When a user enters a screen i call a stored procedure which returns me > a > record or many records and display them in my screen. When they insert > a > record I just call a stored procedure passing over all the screen > values, > and > the same with updating records. At the moment I have not done anything > to > do > with concurrancy in the application so I am open to all ideas. One > idea I > have had is that each table has a "Version" field, and that everytime I > display the data you retrieve the version number, then when you update > a > record you check this version number is still the same in the db, if it > is > then you commit, if its not then you error as someone else must have > updated > that record. But where would this code go? do I put this in each > stored > proc or do I have a generic stored proc for it or to I code it into the > screen? > > Thanks > > Steve
Steve wrote: Visual Studio 2003 .Net / C# / SQL 2000
I am trying to work out the best way to ensure data concurrency in my application. All updates and inserts etc are done via stored procedures. When a user enters a screen i call a stored procedure which returns me a record or many records and display them in my screen. When they insert a record I just call a stored procedure passing over all the screen values, and the same with updating records. At the moment I have not done anything to do with concurrancy in the application so I am open to all ideas. One idea I have had is that each table has a "Version" field, and that everytime I display the data you retrieve the version number, then when you update a record you check this version number is still the same in the db, if it is then you commit, if its not then you error as someone else must have updated that record. But where would this code go? do I put this in each stored proc or do I have a generic stored proc for it or to I code it into the screen?
Please read: http://weblogs.asp.net/fbouma/archiv...5/24/7499.aspx
Frans
--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: aurora |
last post by:
Hello!
Just gone though an article via Slashdot titled "The Free Lunch Is Over: A
Fundamental Turn Toward Concurrency in Software"
http://www.gotw.ca/publications/concurrency-ddj.htm]. It argues that the
continous CPU performance gain we've seen is finally over. And that future
gain would primary be in the area of software concurrency taking advantage
hyperthreading and multicore architectures.
Perhaps something the Python interpreter...
|
by: Charlie Williams |
last post by:
I am having difficulty performing updates and deletions
on an Access database using the Update() method of the
OleDBDataAdapter. I can insert rows without a problem,
but I get a concurrency exception when trying to update
or delete.
I am quite sure that no concurrency conflicts actually
exist. Is there a reason why the data adapter I am using
may have a different row version that the database that
it got its data from?
|
by: Suzanne |
last post by:
Hi All
I'm having problems getting my data adapter to throw a concurrency
exception with an INSERT command. I want to throw a concurrency
exception if an attempt is made to enter a row into tb_table when a
row with the same int_UID already exists in there.
Here is my stored procedure:
if not exists (select int_UID from tb_table where int_UID = @aint_UID)
|
by: xAvailx |
last post by:
I have a requirement that requires detection of rows deleted/updated by
other processes. My business objects call stored procedures to create,
read, update, delete data in a SQL Server 2000 data store. I've done
a fair amount of research on concurrency handling in newsgroups and
other resources. Below is what I've come up as a standard for
handling concurrency thru stored procedures. I am sharing with everyone
so I can get some comments...
|
by: Robert Schuldenfrei |
last post by:
Dear NG,
I was about to "improve" concurrency checking with a Timestamp when I
discovered
that my current code is not working. After about a day of beating my head
against the wall, I am turning to the NG in hopes that someone can spot what
I am doing wrong.
Key to this technique working is the SQL UPDATE statement. It is designed
to fail
| |
by: Mike Kelly |
last post by:
I've chosen to implement the "optimistic concurrency" model in my
application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to
my main tables. I read the value of the column in my select, remember it, and
then use it in the update. It works just fine when I have full control of the
whole process.
I want to do the same for my GridView/SqlDataSource combinations. I
typically select from a view and update the corresponding...
|
by: Bob |
last post by:
While testing my my program I came up with a consistency exception. My
program consists of three datagridviews, One called dgvPostes which is the
parent grid and its two children,one called dgvPlans and the other dgvTanks.
What happens is as follows. I will either create or edit a record in the
datagridview dgvPlans and call the Updatedb procedure (code below). The
first save works OK. Then when that is done, on the same record I will try...
|
by: William E Voorhees |
last post by:
I'm updating an Access database in a windows multi-user environment.
I'm using disconnected data
I read data from an Access Data table to a data object
I update the data object from a windows form
I save the data from the data object to the Access Data table using a data
adapter as follows:
|
by: John |
last post by:
Hi
I have a vs 2003 winform data app. All the data access code has been
generated using the data adapter wizard and then pasted into the app. The
problem I have is that I am getting a data concurrency error on
mydataadapter.update() method. I know that there is no data concurrency
problem as I am the only user testing the app. Obviously the error is
misleading. What can I do from here to fix this problem?
Thanks
|
by: John |
last post by:
Hi
I have developed the following logic to handle db concurrency violations. I
just wonder if someone can tell me if it is correct or if I need a
different approach.Would love to know how pros handle it.
Thanks
Regards
|
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...
| |
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...
|
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,...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |