Bound TextBox on form do not reflect changes made to TableAdapter

I have a form with a button with the following code.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Me.StudentsInfoTableAdapter1.UpdateQuery1(915, 5)

Me.StudentsInfoTableAdapter1.Update(Me.BechinotFlatDataSet1.StudentsInfo)

end sub

The button does it's job: it runs the following query: "UPDATE StudentsInfo
SET Paid = @gpaid WHERE (RecordID = @grecordid)"

in the above click the @gpaid=915 and the @grecordid=5.

Everything is fine, the table does update, but the textboxes on the form that are connected to the same StudentsInfoTableAdapter1 through a bindingsource do not show me the changes only if I close the program and the open it again.

I'm devoloping to a device (Pocket PC).

Any Ideas

TIA,

Susan



Answer this question

Bound TextBox on form do not reflect changes made to TableAdapter

  • Bluehunter

    Thanks for your help.

    But.. do you mean that after each single change I do, I will have to clear the datatable and refill it and then point to the place I am - just to see that small change

    Susan

    p.s. I don't know how to clear the datatable.


  • CoreyMc

    yes you have to clear and fill on each update made direcly to the table., unless you were updating in the dataset itself. and when it suits you, call the update method to update the table.

    this should work for now:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Me.StudentsInfoTableAdapter1.UpdateQuery1(915, 5)

    Me.StudentsInfoTableAdapter1.Update(Me.BechinotFlatDataSet1.StudentsInfo)

    Me.BechinotFlatDataSet1.StudentsInfo.clear()

    Me.StudentsInfoTableAdapter1.fill(Me.BechinotFlatDataSet1.StudentsInfo)

    end sub

     why need two updates   

    isnt that enuf  

    Me.StudentsInfoTableAdapter1.UpdateQuery1(915, 5)

    Me.BechinotFlatDataSet1.StudentsInfo.clear()

    Me.StudentsInfoTableAdapter1.fill(Me.BechinotFlatDataSet1.StudentsInfo)

     

     



  • Keithyboy1

    The update command will only affect the records in the database not the records in memory. You should clear your datatable and refill it with the tableadapters fill command.


  • spinnaker15136

    if you are using VS 2003 +,

    in the disgner, when configuring the TableAdapter u can choose to refresh the DataSet after each update.

    it's in the advanced options when building the selecet statment in the tableadapter.

    or try manually refilling the DS.


  • Bound TextBox on form do not reflect changes made to TableAdapter