• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 279
  • Last Modified:

Updating a DataSet

I'm working with datatables in a dataset.  I'm getting the info into a from made up of text boxes with a function with statements like this textbox1.text = dRow("name")....etc.

Now I want to update fields.  So I understand that I need the textbox_changed function.  But I don't know how to do that.  How would be able to modify/edit the data and get it back into the database?  Please provide a example.

Thanks in advance.
  • 2
1 Solution
Sounds like you're doing it the "re-invent the wheel" way.  Visual Basic .NET provides for datbinding in forms, makes what your trying to do so much easier - changes to text box automatically make it back to the underlying datatables.

Here's a quick introduction:
Quick Example:

Pretend I have a DataTable called "dtEmployees" (the table may or may not reside in a dataset - doesn't matter...)
I also have a form with two text boxes, one called txtFirstName, and one called txtLastName...

In the form_load event, I would:
      ... Fill the Datatable here with data...
      'Configure txtFirstName...
      txtFirstName.DataBindings.Add("text", dtEmployees, "FirstName")
      'Configure txtLastName
      txtLastName.DataBindings.Add("text", dtEmployees, "LastName")

Walla!  Data is bound!

To navigate the data, use a BindingManagerBase object:
Sub BtnNext_Press(sender as object, e as event args)
       Dim bmb As BindingManagerBase = Me.BindingContext(dtEmployees)
       if bmb.Count -1 > bmb.Position then bmb.Position += 1
end Sub

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now