Salakhetdinov Shamil
mcp2004 at mail.ru
Thu Mar 13 10:11:06 CDT 2014
Hi Paul -- It should work. How have you "added a datasource and dataset"? It usually happens in reverse order: - 1st - a blank dataset is added; - 2nd - a data table is dragged from 'Server Explorer' window entry and dropped on dataset by thus creating a datasource... Of course there are many other variations... -- Shamil Wednesday, March 12, 2014 6:23 PM UTC from Paul Hartland <paul.hartland at googlemail.com>: >To all, > >Sorry to the Access group for the OT but I do not seem to be getting any >response from the visual basic list. I am what I call a developer dinosaur >I know VBA and VB6, keep trying to learn VB.net and C#, but always get >sidetracked, however after going on a three day introduction course for >ASP.net MVC development using VB.net has got me interested again. I have >SQL Server 2012 Express and Visual Studio 2012 Express installed, I created >a new blank database and as I am just messing about imported the Customers >table from the Northwind sample, I then opened a new Visual Basic project, >kept the form as Form1 and added a datasource and dataset >called TestDataSet, I then dragged the CustomerID field onto the form and >it appeared along with a binding navigator at the top of the form, without >me doing anything the code behind the form looks like this > >Public Class Form1 > > Private Sub CustomersBindingNavigatorSaveItem_Click(sender As Object, e >As EventArgs) Handles CustomersBindingNavigatorSaveItem.Click > Me.Validate() > Me.CustomersBindingSource.EndEdit() > Me.TableAdapterManager.UpdateAll(Me.TestDataSet) > End Sub > > Private Sub Form1_Load(sender As Object, e As EventArgs) Handles >MyBase.Load > 'TODO: This line of code loads data into the >'TestDataSet.Customers' table. You can move, or remove it, as needed. > Me.CustomersTableAdapter.Fill(Me.TestDataSet) > > End Sub >End Class > >So I started up the application and could flick through all the ID's using >the navigation buttons, however if I try to change an ID then click the >save icon on the binding navigator I get the following error: > >An unhandled exception of type 'System.InvalidOperationException' occurred >in Northwind.exe > >Additional information: Update requires a valid UpdateCommand when passed >DataRow collection with modified rows. > >and the line of code Me.TableAdapterManager.UpdateAll(Me.TestDataSet) is >highlighted, I assumed that as the binding navigator was working the save >would too. > >Can anyone tell me what is wrong and/or point me in the right direction to >do this a better way. > >Many thanks in advance for any help on this. > >Kind Regards, > >Paul > >