We help IT Professionals succeed at work.
Get Started

I'm confused about binding controls to data sources in VB.Net

beihudson
beihudson asked
on
321 Views
Last Modified: 2010-04-17
I have a question about binding controls to data sources in VB.Net.

First, my background is as an embedded guy and what you do there is allocate all resources, set things up, and hit the proverbial "go" button and then it just sits and spins until power is cut off.

I've read my Wrox book on VB, read forums on this site, read examples, am about half done my first VB-Sql server project and puzzled and puzzled about this whole "bound data control" concept.

Here's what I've puzzled out so far:

Ya got some controls on a form, with bindable properties that you "bind" to a data source, in my case either a DataSet or a DataView thats filled in with an SQL query.  Great so far.

There's supposed to be a two-way-path that automagically causes changes to the data in the bound forms to be moved down into the DataSet when the user changes it on the form, and vis-versa.  I'm a bit fuzzy on this part.

Sometimes, it seems, you have to re-bind your control to the data source.  Not quite clear on just when you have to do this and why.

My Wrox book example rebinds the controls all the time.  In fact, it seems that after each and every Update to the Database they re-fill the DataSets and rebind the controls.  Now I'm confused.  Dont controls stay bound?  Do they come unbound somehow and need to be bound back again?  Perhaps some super glue and bolts are needed here?

I'm cool on getting data into the DataSets and Views, thats just some SQLCommand objects and that makes sense.  You issue a command against the DB, data in the DB changes.  Update the DataSet, data there changes.  But then there's this bound controls thing.  If I must rebind after each update to the dataset, why bind at all?

Thanks.

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE