I am using Visual Studio 2005 and visual basic.net. I have a vb form that contains a tableadapter bound to an Access table. On the form is a textbox that displays the contents of a specific field in the Access table. This works fine.
On the same form I allow the user to choose a different Access database (one that has an identical schema). I use the following code to do this:
Me.OpenFileDialog.ShowDialog()
If Me.OpenFileDialog.FileName <> "" Then
TC.My.Settings.TCDBConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Me.OpenFileDialog.FileName
Else
MessageBox.Show("The database connection has not changed.", "Choose Database", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
This also works. However, even though the data in the newly chosen database is different, the content of the textbox does not change until the form is closed and reopened.
My question is, once I change the connection, how do I refresh the databindings, tableadapter, bindingsource, etc. or whatever I need to refresh to display the correct data in the textbox?
Thanks.
On the same form I allow the user to choose a different Access database (one that has an identical schema). I use the following code to do this:
Me.OpenFileDialog.ShowDialog()
If Me.OpenFileDialog.FileName <> "" Then
TC.My.Settings.TCDBConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Me.OpenFileDialog.FileName
Else
MessageBox.Show("The database connection has not changed.", "Choose Database", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
This also works. However, even though the data in the newly chosen database is different, the content of the textbox does not change until the form is closed and reopened.
My question is, once I change the connection, how do I refresh the databindings, tableadapter, bindingsource, etc. or whatever I need to refresh to display the correct data in the textbox?
Thanks.