How do I make a function re-read the main table?

ikantspelwurdz

Well-known member
Joined
Dec 8, 2009
Messages
49
Programming Experience
1-3
My project has a data source called "mobdbDataSet" which is an Access database, Office 2007 format.

The first line in Form1_Load is this (auto-generated):
VB.NET:
Me.MainTableAdapter.Fill(Me.MobdbDataSet.main)

I also have a button with a function attached. It looks like this:
VB.NET:
Private Sub B_Select_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B_Select.Click

For Each mr As mobdbDataSet.mainRow In MobdbDataSet.main
<do stuff>
Next
End Sub

Basically, the above function makes it so that when I click on the Select button, it displays data on the screen based on all the info of the database, filtered according to certain criteria. For my intents and purposes, this is actually much faster than running a query, not to mention that the code is much easier to understand and maintain.

However, let's say I run the thing, click the button, and notice an error. I want to be able to switch to MS Access, fix the data, click the Select button again, and see my changes made. If I do that, nothing happens at all when I click Select.

What do I need to change to make it do this?
 
Just figured it out. The function now looks like this:

VB.NET:
Private Sub B_Select_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B_Select.Click

Me.MainTableAdapter.Fill(Me.MobdbDataSet.main)

For Each mr As mobdbDataSet.mainRow In MobdbDataSet.main
<do stuff>
Next

Me.MainTableAdapter.Dispose()

End Sub
 
Back
Top