473,385 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

dataadapter & dataset sychronization/Consistency

I have have database that I'd like to update a numerical field (field1).
However, I make changes to the dataset and then call the dataadapter.Update
function.
Here's the sequence
1. Get value in field1 (from dataset1)
2. field1 = field1 - variable1
3. Call dataadapter.Update(dataset1)
I am wondering if the possibility exist that if 2 users are updating field1
at the same time, then it might lead inconsistent data. If this is so, how
can I avoid this problem.

--
L. A. Jones
Aug 8 '06 #1
2 1341
L.A. Jones,

This is definitely a possibility. This is why you use something like a
timestamp field or a date time field on your column. When you select the
data, you get the timestamp field.

Then, when you update your query, you update the row that corresponds to
the row that has the values. So, if you are using a primary key, you would
say "where key = <key>" to indicate the row to update. You would expand
that to say "where key = <keyand timestamp = <timestamp>". If no rows are
updated, then you know that someone beat you to it.

Here is a page in the MSDN documentation which talks about concurrency
in database operations:

http://msdn2.microsoft.com/en-us/library/aa0416cz.aspx

And here is another that explores using a primary key along with a
timestamp:

http://www.eggheadcafe.com/articles/20050719.asp

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dave" <Da**@discussions.microsoft.comwrote in message
news:80**********************************@microsof t.com...
>I have have database that I'd like to update a numerical field (field1).
However, I make changes to the dataset and then call the
dataadapter.Update
function.
Here's the sequence
1. Get value in field1 (from dataset1)
2. field1 = field1 - variable1
3. Call dataadapter.Update(dataset1)
I am wondering if the possibility exist that if 2 users are updating
field1
at the same time, then it might lead inconsistent data. If this is so, how
can I avoid this problem.

--
L. A. Jones

Aug 8 '06 #2
Thank you.
--
L. A. Jones
"Nicholas Paldino [.NET/C# MVP]" wrote:
L.A. Jones,

This is definitely a possibility. This is why you use something like a
timestamp field or a date time field on your column. When you select the
data, you get the timestamp field.

Then, when you update your query, you update the row that corresponds to
the row that has the values. So, if you are using a primary key, you would
say "where key = <key>" to indicate the row to update. You would expand
that to say "where key = <keyand timestamp = <timestamp>". If no rows are
updated, then you know that someone beat you to it.

Here is a page in the MSDN documentation which talks about concurrency
in database operations:

http://msdn2.microsoft.com/en-us/library/aa0416cz.aspx

And here is another that explores using a primary key along with a
timestamp:

http://www.eggheadcafe.com/articles/20050719.asp

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dave" <Da**@discussions.microsoft.comwrote in message
news:80**********************************@microsof t.com...
I have have database that I'd like to update a numerical field (field1).
However, I make changes to the dataset and then call the
dataadapter.Update
function.
Here's the sequence
1. Get value in field1 (from dataset1)
2. field1 = field1 - variable1
3. Call dataadapter.Update(dataset1)
I am wondering if the possibility exist that if 2 users are updating
field1
at the same time, then it might lead inconsistent data. If this is so, how
can I avoid this problem.

--
L. A. Jones


Aug 8 '06 #3

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

Similar topics

0
by: Mauro Miotello | last post by:
Using VS.Studio.NET, form a DB2 connection i've tried to create a new Dataset from a DataAdapter the new Dataset was not placed on design time page ! If i set to add to an existing Dataset,...
5
by: JJ | last post by:
Hi, I created a DataAdapter, connection object and dataset generated from DataAdapter by dragging DataAdapter compenent to win form. Now in the code behind I want to use that DataAdapter. I go...
13
by: Doug Bell | last post by:
Hi, I thought I had this sorted this morning but it is still a problem. My application has a DataAccess Class. When it starts, it: Connects to a DB (OLE DB) If it connects it uses an...
8
by: Zorpiedoman | last post by:
I keep getting a concurrency exception the second time I make a change and attempt to update a dataadapter. It appears this is by design, so there must be something I can do to avoid it. ...
0
by: davefromalbury | last post by:
I have a gridview connected to a objectdatasource. Can't for the life of me get it to display anything though, always appears empty. The dataset always seems to be filled with records, as the...
2
by: susan.f.barrett | last post by:
Hi, Despite me being able to type the following in to SQL Server and it updating 1 row: > updatestockcategory 1093, 839 In my code, it is not updating any rows. dataSet = new DataSet();
6
by: Rich | last post by:
Dim da As New SqlDataAdapter("Select * from tbl1", conn) dim tblx As New DataTable da.Fill(tblx) '--works OK up to this point da.UpdateCommand = New SqlCommand da.UpdateCommand.Connection =...
0
by: Dave | last post by:
I have have database that I'd like to update a numerical field (field1). However, I make changes to the dataset and then call the dataadapter.Update function. Here's the sequence 1. Get value in...
3
by: Fred Chateau | last post by:
Any obvious reason here why data is not being loaded into the database? SqlDataAdapter dataAdapter = new SqlDataAdapter(sqlCommand); SqlCommandBuilder commandBuilder = new...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...

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.