473,323 Members | 1,551 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,323 software developers and data experts.

Concurrency violation the updatecommand affected 0 records

Hello,
I have a problem whereby I have a datagrid that is bound to a
dataTable.
However occassionally when I edit the datagrid I get the following message.

Concurrency Violation the update Command affected 0 records.

The message appears to be completely random and If I go back out and into
the form again
it may then work properly.
I looked at the value of the updatecommand in the sqldataadapter and it
always says nothing.

Why does this message occur, is it to do with writing null values back to
the database.
The database gets updated when a cell is clicked on the grid using the
CurrentCellchanged event.
I have attached the relevant code for your assistance.

Thanx in advance.

Geri
MyDataGrid.DataSource = MyDataTable

Private Sub MyDataGrid_CurrentCellChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles MyDataGrid.CurrentCellChanged
Dim IntNumRows As Integer = MyDataTable.Rows.Count
IntRowNum = MyDataGrid.CurrentCell.RowNumber

If IntRowNum < IntNumRows Then
Call UpdateTempJobs()
End If

End Sub

Private Sub UpdateTempJobs()
DirectCast(BindingContext(MyDataTable),
CurrencyManager).EndCurrentEdit()
Call DataAccess.UpdateDataSet(MyDataGrid, MySqlDataAdapter,
MyDataTAble)

End Sub

Public Sub UpdateDataSet(ByRef MyDataset As DataSet, ByVal Mysqldataadapter
As SqlDataAdapter, ByVal strTable As String)
Dim objCommandBuilder As New SqlCommandBuilder(Mysqldataadapter)

Mysqldataadapter.Update(MyDataset, strTable)

End Sub
Nov 21 '05 #1
1 7156
Geraldine,

It has probably to do with the updated records in your dataset.
They are not updated when you use by instance autoincrement keys

Than you have after every update to clear the dataset and fill it completly
new especially in a multiuser environment.

I hope this helps?

Cor
Nov 21 '05 #2

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

Similar topics

25
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...
0
by: Silviall | last post by:
Hello, When I update a datatable row in my application, it generates a concurrency exception. I am unique user, and it can't be an error of concurrency. I've read some information about the same...
1
by: Vladimir O¾ura | last post by:
I am building a Pocket PC Application that uses a dataGrid. The dataSource for the dataGrid is a dataView. When I insert a new row into the dataTable it shows up in the dataView aswelll (that's...
0
by: Dzemo | last post by:
i use this code to get data into dataset cmd.CommandType = CommandType.Text cmdUpdate.CommandType = CommandType.Text cmdUpdate.CommandText = "Update BigOne Set Rezultat=? where ID=?" ...
4
by: elziko | last post by:
I have a DataTable which I did use as the source for a DataGrid, teh data table was popeulated form my database and when I made changes in the grid I used the same DataAdapter to chnage the values...
0
by: Steven Nagy | last post by:
Hidey ho, This question relates to IDbDataAdapter, DataSets, XML, and DiffGrams. I have a data adapter of type IDbDataAdapter and a dataset with one table in it, which has one row in it, which...
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...
1
by: Miriam | last post by:
Hello, I got the error "Concurrency violation: the UpdateCommand affected 0 records" while updating some records in the Windows Application. I am using VB.net in VS 2003 and the backend is...
11
by: John | last post by:
Hi I had a working vs 2003 application with access backend. I added a couple fields in a table in access db and then to allow user to have access to these fields via app I did the following; ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.