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 1465
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***@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.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***@discussions.microsoft.com> wrote in message news:8A**********************************@microsof t.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***@discussions.microsoft.com> wrote in message
news:62**********************************@microsof t.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***@discussions.microsoft.com> wrote in message news:8A**********************************@microsof t.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...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |