An Introduction to VB.NET and Database Programming

Finishing Up

Adding data is done by first clearing the fields and then using the BindingManager to add a new row. Then the user must fill out the text fields and click the update button. The code for the Add button and Update button is below:

Private Sub btnAdd_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
     txtTitle.Text = ""
     bNewRow = True Me .SetEntryControls( True )
     Me.SetMaintenanceButtons( False )
     Me.SetComboBoxControls( False )
     cboCategory.Enabled = True
     txtCategory.Visible = True
     lblCategoryText.Visible = True
End Sub

Private Sub btnUpdate_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click

If ValidData() Then
     If bNewRow Then
          cboRecipe.SelectedIndex = RecipesBindingManager.Count - 1
          bNewRow = False
     End If
     Me.SetEntryControls( False )
     Me.SetComboBoxControls( True )
     btnUpdate.Enabled = False
     Me.SetMaintenanceButtons( True )
     EditMode = False
End If

txtCategory.Visible = False
lblCategoryText.Visible = False

End Sub

That covers the basics of how to use your data connections, data adapters, and data sets to retrieve, navigate, add, delete and update data. I hope that these simple instructions have helped you gain a better understanding of how to manipulate a DataSet. Please feel free to write me or post your comments here about your experiences. There will be more of these beginner type articles as well as book reviews from a beginner's perspective to help guide those of us that are new to the world of Visual Basic.

You might also like...



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.

“UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity.” - Dennis Ritchie