473,473 Members | 2,073 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Concurrency violation - concurrency_error_watch.xls (0/1)

I'm having trouble updating from a datagrid. It's says "Concurrency
violation: the UpdateCommand affected 0 records", though I can't see
how it's related to "concurrency". I can insert and delete with no
problem. Here's the code that's causing the problem:

public void UpdateDataSource(Dancers.allbookings ChangedRows)
{
try
{
if ((ChangedRows != null))
{
this.oleDbConnection1.Open();
oleDbDataAdapter1.Update(ChangedRows);
}
}
catch (System.Exception updateException)
{
throw updateException;
}
finally
{
this.oleDbConnection1.Close();
}

}

An error occurs trying to execute the line:

oleDbDataAdapter1.Update(ChangedRows);

I found nothing wrong when trying to track from the watch list the
data from the row to be updated, as below (can be viewed a lot clearer
from the attached excel file):

- ChangedRows.tbprivate[0]
{Dancers.allbookings.tbprivateRow}
Dancers.allbookings.tbprivateRow
+ System.Data.DataRow {Dancers.allbookings.tbprivateRow}
System.Data.DataRow
cancelled FALSE bool
dancerid 6 int
finished TRUE bool
len 20 byte
pclub 30 short
pdancer 55 short
privateid 65 int
room A string
+ shift {8/2/2004} System.DateTime
start 20:20 string
+ tabletbprivate {Dancers.allbookings.tbprivateDataTable}
Dancers.allbookings.tbprivateDataTable
ChangedRows.Tables["tbprivate"].Rows[0].RowError
Concurrency violation: the UpdateCommand affected 0 records. string
Jul 21 '05 #1
25 2355
Cor
Hi Nick,

When you do it this way,
oleDbDataAdapter1.Update(ChangedRows);


I asume that ChangedRows is the dataset.ChangedRows than the acceptchanges
is not done automaticly by the oleDbDataAdapter, the next time you do than
an update you get a concurrency errror.

Can it be that?

Cor
Jul 21 '05 #2
On Tue, 10 Feb 2004 13:37:59 +0100, "Cor" <no*@non.com> wrote:
Hi Nick,

When you do it this way,
oleDbDataAdapter1.Update(ChangedRows);


I asume that ChangedRows is the dataset.ChangedRows than the acceptchanges
is not done automaticly by the oleDbDataAdapter, the next time you do than
an update you get a concurrency errror.

Can it be that?

Cor


OK here's the code sequece: When the update button is pressed,
"UpdateDataSet" is called:

public void UpdateDataSet()
{
Dancers.allbookings objDataSetChanges = new
Dancers.allbookings();

this.BindingContext[objallbookings,"tbprivate"].EndCurrentEdit();
objDataSetChanges =
((Dancers.allbookings)(objallbookings.GetChanges() ));

// Check to see if any changes have been made.
if ((objDataSetChanges != null))
{
try
{
this.UpdateDataSource(objDataSetChanges);
objallbookings.Merge(objDataSetChanges);
objallbookings.AcceptChanges();
}
catch (System.Exception eUpdate)
{
throw eUpdate;
}
}
}

which then calls "UpdateDataSource" from:

this.UpdateDataSource(objDataSetChanges);

"objDataSetChanges" is passed in as "ChangedRows" to
"UpdateDataSource". As mentioned before, it breaks down when executing
"oleDbDataAdapter1.Update(ChangedRows)" within "UpdateDataSource". I
suspect there's some data inconsistency but by looking at the
"ChangeRows" (which only have 1 row in this case) it all seems fine.
Jul 21 '05 #3
Hello Nick,

Thanks for your post. As I understand, the problem you are facing is that
it throws DBConcurrencyException when calling DbDataAdapter.Update method.
By default, the Update method ends and raises a DBConcurrencyException
exception when the method encounters a row that fails to update. I think
more information is needed before moving forward:

1. What's the database, SQL Server, Microsoft Access, etc?

2. In the DataRow, does it contain the "System.Data.OleDb.OleDbType.DBDate"
type for mapping DateTime data? If so, based on my experience, there is a
known issue to cause such error and we need to use
System.DataOleDb.OleDbType.Date instead of
System.Data.OleDb.OleDbType.DBDate.

3. If the problem persists, is it possible for you to post a sample project
and database which is able to reproduce the problem? I will be glad to
check it on my side.

I look forward to hearing from you.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #4
On Wed, 11 Feb 2004 05:36:23 GMT, ti******@online.microsoft.com (Tian
Min Huang) wrote:
Hello Nick,

Thanks for your post. As I understand, the problem you are facing is that
it throws DBConcurrencyException when calling DbDataAdapter.Update method.
By default, the Update method ends and raises a DBConcurrencyException
exception when the method encounters a row that fails to update. I think
more information is needed before moving forward:

1. What's the database, SQL Server, Microsoft Access, etc?
It's MSAccess.

2. In the DataRow, does it contain the "System.Data.OleDb.OleDbType.DBDate"
type for mapping DateTime data? If so, based on my experience, there is a
known issue to cause such error and we need to use
System.DataOleDb.OleDbType.Date instead of
System.Data.OleDb.OleDbType.DBDate.


Here's the code to create the updatecommand for oleDbDataAdapter1:

updatesql = "UPDATE tbprivate SET dancerid = @dancerid, len = @len,
start = @start, pdancer = @pdancer, pclub = @pclub, room = @room,
finished = @finished, cancelled = @cancelled, shift = #" + GetShift()
+ "# WHERE privateid = @privateid";

where GetShift() will return a date like "2/8/2004".

oleDbDataAdapter1.UpdateCommand = new
OleDbCommand(updatesql,oleDbConnection1);
oleDbDataAdapter1.UpdateCommand.Parameters.Add("@p rivateid",
OleDbType.BigInt,4, "privateid");
oleDbDataAdapter1.UpdateCommand.Parameters.Add("@d ancerid",
OleDbType.BigInt,4, "dancerid");
oleDbDataAdapter1.UpdateCommand.Parameters.Add("@l en",
OleDbType.TinyInt,1, "len");
oleDbDataAdapter1.UpdateCommand.Parameters.Add("@r oom",
OleDbType.VarChar,1, "room");
oleDbDataAdapter1.UpdateCommand.Parameters.Add("@s tart",
OleDbType.VarChar,5, "start");
oleDbDataAdapter1.UpdateCommand.Parameters.Add("@p club",
OleDbType.TinyInt,4, "pclub");
oleDbDataAdapter1.UpdateCommand.Parameters.Add("@p dancer",
OleDbType.TinyInt,4, "pdancer");
oleDbDataAdapter1.UpdateCommand.Parameters.Add("@f inished",
OleDbType.Boolean,1, "finished");
oleDbDataAdapter1.UpdateCommand.Parameters.Add("@c ancelled",
OleDbType.Boolean,1, "cancelled");
oleDbDataAdapter1.UpdateCommand.Parameters.Add("@s hift",
OleDbType.Date,0, "shift");
Jul 21 '05 #5
Also have you looked at the xls file? Is it useful?

On Wed, 11 Feb 2004 05:36:23 GMT, ti******@online.microsoft.com (Tian
Min Huang) wrote:
Hello Nick,

Thanks for your post. As I understand, the problem you are facing is that
it throws DBConcurrencyException when calling DbDataAdapter.Update method.
By default, the Update method ends and raises a DBConcurrencyException
exception when the method encounters a row that fails to update. I think
more information is needed before moving forward:

1. What's the database, SQL Server, Microsoft Access, etc?

2. In the DataRow, does it contain the "System.Data.OleDb.OleDbType.DBDate"
type for mapping DateTime data? If so, based on my experience, there is a
known issue to cause such error and we need to use
System.DataOleDb.OleDbType.Date instead of
System.Data.OleDb.OleDbType.DBDate.

3. If the problem persists, is it possible for you to post a sample project
and database which is able to reproduce the problem? I will be glad to
check it on my side.

I look forward to hearing from you.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Jul 21 '05 #6
Cor
Hi Nick,

What is the reason you do this,
this.UpdateDataSource(objDataSetChanges);
objallbookings.Merge(objDataSetChanges);
objallbookings.AcceptChanges();


If I see it good you try to merge to the dataset a set of rows which are
already completly in this dataset if the program works correct than that
should give an concurrency error..

I think it is better to do an update of the whole dataset. (I have done it a
while a little bit the same as you although without the merge, I am not
secure if all checkings are done correct with this method).

You do than also not need that acceptchanges, because the dataadapter does
it for you if everything went correct.

Cor
Jul 21 '05 #7
On Wed, 11 Feb 2004 13:02:24 +0100, "Cor" <no*@non.com> wrote:
Hi Nick,

What is the reason you do this,
this.UpdateDataSource(objDataSetChanges);
objallbookings.Merge(objDataSetChanges);
objallbookings.AcceptChanges();

objallbookings is the existing dataset. UpdateDataSource updates the
underlying datasource (actually updating the database). The last 2
lines commits changes to the dataset. How else would you do it??

If I see it good you try to merge to the dataset a set of rows which are
already completly in this dataset if the program works correct than that
should give an concurrency error..
See above.

I think it is better to do an update of the whole dataset. (I have done it a
while a little bit the same as you although without the merge, I am not
secure if all checkings are done correct with this method).


I have been doing it this way ALL the time, only this particular grid
fails me. I am suspecting it's the data in the row(s) that's giving
the underlying database inconsistent update, but I can't figure out
which column, cause as you can see from the watch (excel file) all
data seems pretty normal.

Anyone?
Jul 21 '05 #8
Cor
Hi Nick,

I would first try what I did advice when than the concurrency error is not
gonne than it is something else.

:-)

Cor
I have been doing it this way ALL the time, only this particular grid
fails me. I am suspecting it's the data in the row(s) that's giving
the underlying database inconsistent update, but I can't figure out
which column, cause as you can see from the watch (excel file) all
data seems pretty normal.

Jul 21 '05 #9
On Wed, 11 Feb 2004 14:34:17 +0100, "Cor" <no*@non.com> wrote:
Hi Nick,

I would first try what I did advice when than the concurrency error is not
gonne than it is something else.

:-)

Cor
Umm.. I don't quite understand what you're suggesting. Perhaps some
code might help?
I have been doing it this way ALL the time, only this particular grid
fails me. I am suspecting it's the data in the row(s) that's giving
the underlying database inconsistent update, but I can't figure out
which column, cause as you can see from the watch (excel file) all
data seems pretty normal.


Jul 21 '05 #10
Cor
To test
this.UpdateDataSource(objallbookings);
// objallbookings.Merge(objDataSetChanges);
// objallbookings.AcceptChanges();
Jul 21 '05 #11
On Wed, 11 Feb 2004 15:08:01 +0100, "Cor" <no*@non.com> wrote:
To test
this.UpdateDataSource(objallbookings);
// objallbookings.Merge(objDataSetChanges);
// objallbookings.AcceptChanges();


Umm I thought it was pretty clear I mentioned it's "UpdateDataSource"
that's causing the problem?
Jul 21 '05 #12
Hi Nick,

Thanks for your response. I reviewed your code snippet carefully, I noticed
that "shift" value is directly got from GetShft so that we should not add
@shift parameter to the UndateCommand. Please remove it and then check
whether or not the problem still exists.

I am standing by for your result.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #13
On Thu, 12 Feb 2004 08:30:14 GMT, ti******@online.microsoft.com (Tian
Min Huang) wrote:
Hi Nick,

Thanks for your response. I reviewed your code snippet carefully, I noticed
that "shift" value is directly got from GetShft so that we should not add
@shift parameter to the UndateCommand. Please remove it and then check
whether or not the problem still exists.

I am standing by for your result.
Exactly the same error.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Jul 21 '05 #14
Hi Nick,

Since the problem persists, could you please post a sample project with
MDB file and tell me the detailed steps to reproduce the problem? That
will be most helpful for me to pinpoint the problem and resolution.

I am standing by for your response.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #15
On Fri, 13 Feb 2004 07:43:24 GMT, ti******@online.microsoft.com (Tian
Min Huang) wrote:
Hi Nick,

Since the problem persists, could you please post a sample project with
MDB file and tell me the detailed steps to reproduce the problem? That
will be most helpful for me to pinpoint the problem and resolution.


Do I just email the project (slimmed down version) to you? It's about
1.5mb compressed, including the Access db.
Jul 21 '05 #16
Hello Nick,

You can ZIP the files and email it to me directly. Thanks.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #17
On Fri, 13 Feb 2004 11:30:56 GMT, ti******@online.microsoft.com (Tian
Min Huang) wrote:
Hello Nick,

You can ZIP the files and email it to me directly. Thanks.


Did you get the email? I sent it to timhuang at microsoft dot com.
Jul 21 '05 #18
Hi Nick,

Thanks for your project. I received it and am now performing research on
it. I will update you with my information.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #19
On Mon, 16 Feb 2004 10:43:50 GMT, ti******@online.microsoft.com (Tian
Min Huang) wrote:
Hi Nick,

Thanks for your project. I received it and am now performing research on
it. I will update you with my information.


Thanks for your help. Waiting for the good news :)
Jul 21 '05 #20
Hi Nick,

I reproduced the problem on my side. However, due to the complexity of this
issue, I will need more time to investigate. Thanks for your patience.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #21
On Wed, 18 Feb 2004 16:27:27 GMT, ti******@online.microsoft.com (Tian
Min Huang) wrote:
Hi Nick,

I reproduced the problem on my side. However, due to the complexity of this
issue, I will need more time to investigate. Thanks for your patience.


No worries. Thanks again for your help.
Jul 21 '05 #22
On Wed, 18 Feb 2004 16:27:27 GMT, ti******@online.microsoft.com (Tian
Min Huang) wrote:
Hi Nick,

I reproduced the problem on my side. However, due to the complexity of this
issue, I will need more time to investigate. Thanks for your patience.


Don't mean to rush you but just like to know if you have any progress.

Cheers.
Jul 21 '05 #23
Hi Nick,

This issue seems strange. To narrow down the problem, I built a simple
project of my own which works properly on updating the dataset. I am now
digging into your project to see what's going wrong.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #24
Hello Nick,

Thanks for your patience. After further research on this issue, I found out
that the problem was caused by the improper order of SQL parameters. Based
on my research, the OLE DB Provider handles parameters differently than
SQLClient which accepts named parameters. Please adding the parameters in
the correct order and see if it works on your side:

oleDbDataAdapter1.UpdateCommand.Parameters.Add("@d ancerid",
OleDbType.BigInt,4, "dancerid");
oleDbDataAdapter1.UpdateCommand.Parameters.Add("@l en", OleDbType.Integer,1,
"len");
oleDbDataAdapter1.UpdateCommand.Parameters.Add("@s tart",
OleDbType.VarChar,5, "start");
oleDbDataAdapter1.UpdateCommand.Parameters.Add("@p dancer",
OleDbType.Integer,2, "pdancer");
oleDbDataAdapter1.UpdateCommand.Parameters.Add("@p club",
OleDbType.Integer,2, "pclub");
oleDbDataAdapter1.UpdateCommand.Parameters.Add("@r oom",
OleDbType.VarChar,1, "room");
oleDbDataAdapter1.UpdateCommand.Parameters.Add("@f inished",
OleDbType.Boolean,1, "finished");
oleDbDataAdapter1.UpdateCommand.Parameters.Add("@c ancelled",
OleDbType.Boolean,1, "cancelled");
oleDbDataAdapter1.UpdateCommand.Parameters.Add("@p aid",
OleDbType.Boolean,1, "paid");
oleDbDataAdapter1.UpdateCommand.Parameters.Add("@p rivateid",
OleDbType.BigInt,4, "privateid");

I am standing by for your result.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #25
On Thu, 26 Feb 2004 01:56:48 GMT, ti******@online.microsoft.com (Tian
Min Huang) wrote:
Hello Nick,

Thanks for your patience. After further research on this issue, I found out
that the problem was caused by the improper order of SQL parameters. Based
on my research, the OLE DB Provider handles parameters differently than
SQLClient which accepts named parameters. Please adding the parameters in
the correct order and see if it works on your side:


Damn didn't think of that possibility... Thanks a bunch!

Gotta read more into OleDbCommand.Parameters when I got time :)
Jul 21 '05 #26

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

Similar topics

2
by: Billy Jacobs | last post by:
I have a client who is getting a concurrency violation error whenever she tries to update a record. I can log in to the site as her simultaneously and update the record with no problem. I can...
3
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...
2
by: Niyazi | last post by:
Hi, I have not understand the problem. Before all the coding with few application everything worked perfectly. Now I am developing Cheque Writing application and when the cheque is clear the...
1
by: nick | last post by:
I'm having trouble updating from a datagrid. It's says "Concurrency violation: the UpdateCommand affected 0 records", though I can't see how it's related to "concurrency". I can insert and delete...
4
by: Steven Nagy | last post by:
Hi Have a problem that consistantly occurs in my applications where using a DataAdapter (OLEDB) and a dataset. Using a simple process of adding a row to the dataset table and then calling the...
2
by: Vladimir O¾ura | last post by:
I am building a pocket pc application that requires a datagrid. I am inserting a new row this way: private void mInsert_Click(object sender, System.EventArgs e) { try { DataRow dr =...
4
by: Jerry | last post by:
Hi, I have an app which retrieves data from a sql server table and displays it on a datagrid. If 2 sessions of this app are running and 2 users try to update the same record at about the same...
2
by: Agnes | last post by:
I got a simple form and using databinding manager to do the add new Now , my big trobule is . I can update the 'addnew' record, However, after I new the record, and then amend it , it got...
5
by: Vayse | last post by:
In my save code, most of items save fine. But sometimes I get a concurrency violation message. "Concurrency violation: the UpdateCommand affected 0 of the expected 1 records." It happens on the...
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,...
0
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
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...
1
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...
0
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,...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 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.