Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
| Search | Today's Posts | Mark Forums Read
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 5th, 2008, 10:33 PM
Registered User
Join Date: Jan 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default concurrency violation updating child table

Hey everyone,

I have 3 tables in an Access database - tblMain, tblDelivery, and tblOtherCosts. tblMain is the parent table with a primary key (ID) and tblDelivery and tblOtherCosts are detail tables with foreign keys (ID) in a one to many relationship with tblMain. Update and delete events are set to cascade (via Dataset Designer in VB 2008).

I display data from all three tables on a form: I have a DataGridView bound to tblMain. tblDelivery and tblOtherCosts have their respective textboxes (bound to the appropriate fields) on the form. tblMain also has a DataNavigator on the form.

I fill the dataset with:

Me.TblOtherCostsTableAdapter.Fill(Me.SpDataSet.tbl OtherCosts)
          Me.TblDeliveryTableAdapter.Fill(Me.SpDataSet.tblDe livery)

To save changes to the database, I use the following:

Private Sub TblMainBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TblMainBindingNavigatorSaveItem.Click

End Sub

If I edit a value in the databound text box for tblDelivery or tblOtherCosts and try to save it (update) I get "Concurrency violation: the UpdateCommand affected 0 of the expected 1 records". Does anyone know why this is, and how I should modify my code to fix it?
Old January 27th, 2008, 02:29 AM
Registered User
Join Date: Jan 2008
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts

I don't know if this helps but it did give me better understanding of updating related tables:

It is a 13 minutes video Presented by Beth Massi (Microsoft) on the subject.


- Tsadok

Similar Threads
Thread Thread Starter Forum Replies Last Post
Concurrency Violation Exception Olorin ADO.NET 10 October 4th, 2007 12:21 PM
Concurrency Violation Problem - Please HELP! Aaron Edwards ASP.NET 2.0 Basics 0 March 25th, 2007 08:17 PM
Concurrency Violation Problem - Please HELP! Aaron Edwards ADO.NET 1 March 25th, 2007 08:15 PM
Update parent table with the sum of child table gbrown SQL Language 2 November 9th, 2004 07:53 AM
Concurrency Violation performing Database updates LaFeverMF VB Databases Basics 1 February 15th, 2004 01:51 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.