Activate Save button in BindingNavigator

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • reidarT

    #1

    Activate Save button in BindingNavigator

    I have entered a BindingNavigato r toolbar in a bound form and can manage to
    browse records and I am able to enter data in a new record.
    I am ot able to save the data and therefore I have entered the save-button.
    How do I code this button to save a new record?
    reidarT


  • gene kelley

    #2
    Re: Activate Save button in BindingNavigato r

    On Thu, 23 Feb 2006 21:54:50 +0100, "reidarT" <reidar@eivon.n o> wrote:
    [color=blue]
    >I have entered a BindingNavigato r toolbar in a bound form and can manage to
    >browse records and I am able to enter data in a new record.
    >I am ot able to save the data and therefore I have entered the save-button.
    >How do I code this button to save a new record?
    >reidarT
    >[/color]
    I'm new at this myself, but this may help.

    It depends on how your DataSet was filled. If from a single table (no
    joins), a primary key exists, and none of the column names are
    deliniated by "[ ]" in the fill SQL statement, the 'automated'
    UpdateMethod should work.

    Assuming a dataset named MyDataSet, a bindingsource named
    MyBindingSoure, a tableadapter named MyTableAdapter and a table named
    MyTable, this code would generally work if the above criteria are
    satisfied:

    Private Sub btnUpdate_Click (ByVal sender As Object, ByVal e As _
    System.EventArg s) Handles btnUpdate.Click
    If Me.Validate() = True Then
    Me.MyBindingSou rce.EndEdit()
    Me.MyTableAdapt er.Update(Me.My DataSet.MyTable )

    Else
    'there were validation errors
    End If
    End Sub

    In the above example, the Update statement can throw an exception if
    above criteria do not apply telling you that you need a valid Update
    Command. I did somthing like this last week with an Access DB. At
    first, the update would not work. Turned out that one of the columns
    in the DB was named "Size" and appeared in the SQL statement as
    [Size]. I renamed the column and the update then worked.

    Gene

    Comment

    Working...