locked
Update Doesn't Always work... RRS feed

  • Question

  • I have a list box that displays last names from a query.  When there is more than one last name returned in the query you select the entry you want and the remaining fields appear in individual boxes that allow editing and saving.  My problem is editing and saving only works for the first name in the list box (index 0).  When I try to edit and save anything other than the first item, it appears to save and even shows the updated information in the list box but when the user re-queries the data it reverts back to its previous value.

     

    Here is my code for saving the record, keep in mind it always works for index 0 but not for any other index of the list box.

     

        Private Sub SaveRecord()

     

            Try

     

    'Use the BindingContext Class to end current editing so that we can update 'the server

                Me.EmployeeBindingSource.EndEdit()

                'Perform the requested task at the dataset level using the data adapter

                Me.EmployeeTableAdapter.Update(EmployeeDataSet.employee)

                'Unsure about this, doesn't appear to be necessary

                Me.EmployeeDataSet.employee.AcceptChanges()

     

            Catch saveEx As Exception

     

                MessageBox.Show(saveEx.Message)

     

            End Try

        End Sub

     

    I'm connecting to a MySQL database using connector/Net - visual studio 2005 standard.

    Wednesday, September 26, 2007 8:59 PM

Answers

  • I bound the list box and accompanying fields to a 'list instance' under Other Datasources instead of directly to the binding source.  Once I bound them directly to the binding source everything worked fine.

     

    Thursday, September 27, 2007 3:01 PM

All replies

  • Is this the correct forum?

    Thursday, September 27, 2007 2:21 PM
  • I bound the list box and accompanying fields to a 'list instance' under Other Datasources instead of directly to the binding source.  Once I bound them directly to the binding source everything worked fine.

     

    Thursday, September 27, 2007 3:01 PM