[dba-VB] VB.net data bound form problem

Dan Waters df.waters at comcast.net
Wed Mar 12 13:45:48 CDT 2014


Hi Paul,

Probably the best place to get help with VB.Net (or anything else with
Visual Studio is StackOverflow.com.  Register as a new user and ask your
question - the people who answer get 'points' so you'll probably get some
response pretty quickly.

Also, if you just do a normal google search many of the hits will be on
StackOverflow.com.

Good Luck,
Dan

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Paul Hartland
Sent: Wednesday, March 12, 2014 1:24 PM
To: VisualBasicList; Access List
Subject: [dba-VB] VB.net data bound form problem

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


--
Paul Hartland
paul.hartland at googlemail.com
_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com



More information about the dba-VB mailing list