• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 424
  • Last Modified:

Form Data Binding Confusion

I've got a similar issue to the question posed on EE here; http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_23022296.html but the resolution doesn't work with mine.

Basically I have a MSSQLCE database with a number of tables, which has been added to my vb 2005 project as a datasource, and I have created a standard form which has had the fields bound to the datasource by dragging and dropping from the datasource tab onto the form.  There is also a 'New' and a 'Save' button.

Clicking the 'New' button does the following:
        Me.ChannelsBindingSource.AddNew()

I can then enter data onto the form and click the 'Save' button' to save the data, which does the following:
                Me.Validate()
                Me.ChannelsBindingSource.EndEdit()
                Me.ChannelsTableAdapter.Insert(Me.tbChannels.Text)
                Me.ChannelsTableAdapter.Update(Me.MiV2DataSet)

(There are actually more fields than specified in the Insert)

Now this works, but I would have thought one of the advantages of databinding was that I shouldn't have to specify every field that needs to be inserted and the code in the link above seems to back this up.

Any help would be appreciated.

0
nurcombe
Asked:
nurcombe
1 Solution
 
VBRocksCommented:
No, you shouldn't need to do that.

Check and make sure the controls are bound to the bindingsource.

Right-Click on the textbox, select Properties.  In the Properties window, go to the top, expand "DataBindings" and make sure the Text property is bound to the BindingSource and field.
0
 
nurcombeAuthor Commented:
Found the problem, rather than
    Me.ChannelsTableAdapter.Update(Me.MiV2DataSet)

I needed to have
    Me.ChannelsTableAdapter.Update(Me.MiV2DataSet, Channel)

Many thanks for trying to help.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now