5 Replies - 383 Views - Last Post: 22 January 2014 - 06:39 AM Rate Topic: -----

#1 Clamont  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 20-January 14

Updating a Current Record Using BindingNavigator

Posted 20 January 2014 - 07:38 AM

I have connected to a database(MYSql 5.6) and using a form have binded the table and added a navigator.

I have adjusted the xsd file to 'copy if newer' in the copy to output directory

I am able to delete records after attaching the following code

Private Sub BindingNavigatorDeleteItem_Click(sender As Object, e As EventArgs) Handles BindingNavigatorDeleteItem.Click
        'Delete Current Record
        'We to add validation routines to ensure we can delete this record safely
        '***********************************************
        MyMsg(0) ' Ask the user if they want to delete the record.
        If Gvar.MsgResult = MsgBoxResult.Yes Then
            Me.BindingSource1.RemoveCurrent()
            Me.BindingSource1.EndEdit()
            Me.CourtTableAdapter.Update(Me.Jigsaw2DataSet.court)
        End If
    End Sub



However try as I might I can not get the form to update a current record after adding the following code

 Private Sub SaveToolStripButton_Click(sender As Object, e As EventArgs) Handles SaveToolStripButton.Click
        Me.Validate()
        Me.BindingSource1.EndEdit()
        Me.CourtTableAdapter.Update(Me.Jigsaw2DataSet.court)
    End Sub



The record just reverts to its original data.

I have checked that the user being used to access the SQL has full access rights, and its does. I am using the root user to ensure there are no permission issues.

I am sure I am missing some setting, but just can't find it

Any help would be most appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: Updating a Current Record Using BindingNavigator

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 2885
  • View blog
  • Posts: 9,580
  • Joined: 12-December 12

Re: Updating a Current Record Using BindingNavigator

Posted 20 January 2014 - 08:15 AM

I am not sure what the issue is, so only have a suggestion to try:

    Me.CourtTableAdapter.UpdateAll(Me.Jigsaw2DataSet)

Was This Post Helpful? 0
  • +
  • -

#3 Clamont  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 20-January 14

Re: Updating a Current Record Using BindingNavigator

Posted 20 January 2014 - 08:58 AM

Adding UpdateALl displays the error that UpdateALL is not a member of the CourtTableAdapter. A colleage suggests using hard coded SQL statement within the save function, but I think this is a bit of an overkill. I don't really want SQL statements embedded in my code.
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 2885
  • View blog
  • Posts: 9,580
  • Joined: 12-December 12

Re: Updating a Current Record Using BindingNavigator

Posted 20 January 2014 - 09:16 AM

Sorry, that should be:
Me.TableAdapterManager.UpdateAll(Me.Jigsaw2DataSet)

but this would only apply if your DataSet contains related tables.

Saving Data from Related Tables :MSDN
Was This Post Helpful? 0
  • +
  • -

#5 Clamont  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 20-January 14

Re: Updating a Current Record Using BindingNavigator

Posted 21 January 2014 - 02:51 AM

Have tried the above addition
Private Sub SaveToolStripButton_Click(sender As Object, e As EventArgs) Handles SaveToolStripButton.Click
        Me.Validate()
        Me.BindingSource1.EndEdit()
        'Me.CourtTableAdapter.Update(Me.Jigsaw2DataSet)
        Me.TableAdapterManager1.UpdateAll(Me.Jigsaw2DataSet)
    End Sub



However record still does not save, and resets the current record to its original values

Would it be some internal setting that's preventing updates?
Was This Post Helpful? 0
  • +
  • -

#6 Clamont  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 20-January 14

Re: Updating a Current Record Using BindingNavigator

Posted 22 January 2014 - 06:39 AM

It would seem that my TableAdapterManager was not set correctly.

At the bottom of the form I should have the following :-

Dataset
BindingSource
TableAdapter
TableAdapterManager
BindingNavigator

The tableadaptermanager was the root of the problem,

Thanks andrewse, pointed me in the right direction.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1