SImple ADO.Net problem

  • Thread starter Thread starter Grumpy Aero Guy
  • Start date Start date
G

Grumpy Aero Guy

Set up a simple ADO.Net Windows app. Set everything up... fill data via

*******************************************************************
Dim bmb As BindingManagerBase

:

:

Private Sub MemberDetail_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Me.daTrain.Fill(dsTrain.tblMaster)

bmb = Me.BindingContext(dsTrain.tblMaster)

End Sub

*******************************************************************

Simple form with 3 text boxes representing three particular fields in the
table via data binding to appropriate fields.

Run App....

First record appears in text boxes as expected. so far so good....

Created a "Move Next Button via:

*******************************************************************

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

bmb.Position += 1

End Sub

*******************************************************************

Click button ... and... nothing. Can't get the record position to move on
the form.

So what stupid, simple thing am I overlooking??????
 
Your controls are probably not using that same bindingcontext. Try

bmb = Me.BindingContext(dsTrain, "tblMaster")
This returns a *different* binding manager than
BindingContext(dsTrain.tblMaster) believe it or not and it's probably the
one your controls are using.

Suggestion:
Because of BindingContext/BindingManager's trickyness... I have found it
infinitely helpful to use a DataView and bind to that rather than binding to
the dataset tables directly. It's simple, just drop a DataView onto your
form, associate it with the table, and change all your binding to use the
DataView.

Using DataViews solves all the confusing nuances with databinding.
 
I changed it to xxxxx, "tblMaster" instead of xxxxx.tblmaster....

YOU WERE RIGHT....

Geez.... a little touchy I think.

I will research the dataview component.

Thank you !!!!!!!!!!
 
Yeah. Watch out this other non-intuitive "gotcha" below (but don't let these
"gotcha's" discourage you, once you wrap your mind around them, databinding
is extremely beneficial... and full-featured).

For instance, using a Datagrid:

DataSource=MyDataset1, DataMemeber=Table1
or
DataSource=MyDataset1.Table1

accomplish the same thing but produce DIFFERENT binding managers. Don't ask
me why. It leads to confusion when you try to create a Master/Details user
interface and then you can't figure out why your Details controls (textboxes
and stuff) don't sync up with your Master control (Datagrid for example)...
it's because behind the scenes they're using different CurrencyManagers.

Again, binding everything to DataView(s) simplies everything greatly. Plus
DataViews add additional features that Datasets don't possess. I like to
make it a "standard practice" to exclusively using binding with DataViews
rather than to the Dataset directly.
 
Back
Top