Textbox.databinding.add - Does not write back to Underlying table

  • 12 years ago


    I have a form with a few text boxes. All of them are bound to a table in a SQL database as follows in the Form Load event.

    textbox1.databindings.add(new binding("Text", ds.tables(0), "id")
    textbox2.databindings.add(new binding("Text", ds.tables(0), "Name")

    When the form is loaded, I create a new record into the table with the following code.

    dim dr as datarow
    dr = ds.tables(0).newrow

    dr("id") = 1
    dr("Name") = "Hello"

    The information that I have passed into the datarow (dr) comes visible into the text boxes when the form is displayed....but...if I go and change the word "Hello" to "Hello123" (just for testing purpose)...and press the save button (which runs the update code as below)...I expect the revised "Hello123" to be written back to the table in SQL. But this does not happen...where as the word "Hello" gets written back.

    private sub Save()

    dim dtnew as datatable
    dtnew = ds.tables(0).getchanges(datarowstate.added)


    end sub

    Can anyone tell me what I am doing wrong or am I missing something somewhere. Need your assistance desperately.

    Best Rgds

  • 11 years ago

    Although this is an old post - I think for other readers out there...

    This is line with the issue: dtnew = ds.tables(0).getchanges(datarowstate.added) Specifically - datarowstate.added I think you need to include changed row data - because you added the row in one part, and then changed it in another

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Perl - The only language that looks the same before and after RSA encryption.” - Keith Bostic