How to open a different table using the same bindingsource -

I have a simple Winforms App - with a database with 2 tables (tableOne TableTwo)
The form has 1 textbox that is bound to the dataset for tableOne.
There is no coding at this time.  
Run the program - Textbox shows the first record of the tableOne

The form has 1 button that says change table.
However, (when coding) - when I attempt to change TextBox from one table to another,
all I get is errors.

The database is the same - there is only 2 tables - how can I switch between the two tables for
textbox to display - when I click the button?

Thank You!
Michael MeeksSystems ManagerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Strictly speaking TextBox can not be bound to "Table" or "Record". It's bound to table (record) field (column). When you say "There is no coding at this time" - it's incorrect also - the code is in form designer. It's look smth like this:
Dim ds As New DataSet
Dim da1 As New SqlDataAdapter("SELECT * FROM Table1", connString)
da1.Fill(ds, "Table1")
Dim da2 As New SqlDataAdapter("SELECT * FROM Table2", connString)
da2.Fill(ds, "Table2")
Dim bs As New BindingSource(ds, "Table1")
TextBox1.DataBindings.Add("Text", bs, "ColumnName")

Open in new window

If both tables have same ColumName you can just  change bs.dataMember:
bs.dataMember = "Table2"

Open in new window

Otherwise you need reset TextBox1.DataBindings (I suggest using second bindinSource for that):
Dim bs2 As New BindingSource(ds, "Table2")
Private Sub Button_Click(s,e) Handles....
     Dim bs = If(TextBox1.DataSource Is bs1, bs2, bs1)
     Dim colName = If(TextBox1.DataSource Is bs1, "AnotherColumnNAme", "ColumnName")
    ' or
    ' TextBox1.DataBindings.RemoveAt(0)
     TextBox1.DataBindings.Add("Text", bs, colName)
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Michael MeeksSystems ManagerAuthor Commented:
Thank You !   Although VB2017 - doesn't like your (method 2 shown) - since in 2017 it has changed.

IDE0017 Object initialization can be simplified pops up.

BC30455 Argument no specidifed for parmeter "metadataChange of 'Public Overloads Sub ResetBindings(metadataChanged as boolean)

When I remove method 2 - these both go away!

Strange,  But I do thank you for steering me in the right direction.  It's a big help.

Thank You!
(Error) BC30455 Argument no specidifed for parmeter "metadataChange of 'Public Overloads Sub ResetBindings(metadataChanged as boolean)
Sorry, should be bs.ResetBindings(False)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.