473,808 Members | 2,838 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Upd ate
function.
Here's the sequence
1. Get value in field1 (from dataset1)
2. field1 = field1 - variable1
3. Call dataadapter.Upd ate(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 1359
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.co m

"Dave" <Da**@discussio ns.microsoft.co mwrote in message
news:80******** *************** ***********@mic rosoft.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.Upd ate
function.
Here's the sequence
1. Get value in field1 (from dataset1)
2. field1 = field1 - variable1
3. Call dataadapter.Upd ate(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.co m

"Dave" <Da**@discussio ns.microsoft.co mwrote in message
news:80******** *************** ***********@mic rosoft.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.Upd ate
function.
Here's the sequence
1. Get value in field1 (from dataset1)
2. field1 = field1 - variable1
3. Call dataadapter.Upd ate(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
1062
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, then it was placed on design time page. Someone have a solution ? thanks
5
4582
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 to use the dataset that was generated from DataAdapter and I get an Object ref error. So do I have to go through the steps in code behind to reinitate the SqlDataAdapter and DataSet that I generated on the form? If so whats the purpose of having...
13
2094
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 OleDbCommand with an SQL String and the connection it has a DataAdapter with the command then it fills the DataSet's DataTable with the streamed data.
8
2700
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. Example: I have a dataadapter that contains one table with one row. I change the value of the 'FisrtName' column in that row from Jack to John. I call ..update on the dataadapter it goes through fine. Now I change that same column in that same row...
0
1148
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 variable "x" always equals the number of records i expected. The business object select command: public static DataSet Select() { DataSet dataSet = new DataSet(); SqlDataAdapter dataAdapter = new SqlDataAdapter();
2
13971
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
14005
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 = conn da.UpdateCommand.CommandText = "Update tbl1 set fld1 = 'test' where ID = 1" da.Update(tblx) '--tblx/tbl1 not getting updated here.
0
1007
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 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...
3
2353
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 SqlCommandBuilder(dataAdapter); dataAdapter.Fill(dataSet, "POI_Entity"); DataRow dataRow = dataSet.Tables.NewRow(); dataRow = 1; dataRow = dataSet.Identity.POI_Entity_ID; dataRow = dataSet.Identity.Chain_ID;
0
10628
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...
1
10374
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,...
1
7651
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
6880
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
5547
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...
0
5685
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
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 we have to send another system
2
3859
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
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.