Results 1 to 5 of 5

Thread: update bindingsource

Threaded View

  1. #1

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    update bindingsource

    I have a dataset (dS), adapter(aD) and bindingsource(bS) I am using in a form. The datasource for bS is dS, and I am filling the adapter in the form's Load event with a table (tbl) from the dataset.

    On the form I have a listbox and a textbox with the following properties set

    ListBox.DataSource = bS
    ListBox.DisplayMember = <coloumn 1 of tbl>

    The textbox.text property is bound to <column 2 of tbl>

    When I change the selected item of the listbox, the text in the textbox changes to the appropriate data from the dataset, so I know that part of what I am doing works.

    When I change the text in the textbox however, the database is not updating, and I assume I am missing something small.
    my code....

    vb Code:
    1. Public Class RecipeTypesForm
    2.  
    3.     Private Sub RecipeTypesForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.  
    5.         Me.RecipeTypesTableTableAdapter.Fill(Me.BrewBaseDataSet.RecipeTypesTable)
    6.  
    7.     End Sub
    8.  
    9.     Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
    10.  
    11.         Dim i As Integer = ListBox1.SelectedIndex
    12.         If i > -1 Then
    13.             Me.RecipeTypesTableBindingSource.Position = i
    14.         End If
    15.  
    16.     End Sub
    17.  
    18.     Private Sub OKButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OKButton.Click
    19.  
    20.         Me.RecipeTypesTableTableAdapter.Update(Me.BrewBaseDataSet.RecipeTypesTable)
    21.         Me.Close()
    22.  
    23.     End Sub
    24.  
    25. End Class
    I am guessing I am not updating something correctly to finalize the change in the database when I close the form. Can any one see what I am not doing right?
    thanks
    kevin
    Last edited by kebo; Oct 25th, 2010 at 11:49 AM.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width