BindingContext & CurrencyManager

  • Thread starter Thread starter Blake Weaver
  • Start date Start date
B

Blake Weaver

I'm trying get at the underlying data in the form's currencymanager. I found
an example in the Microsoft Press book "ADO.NET Step by Step" but I'm having
problems with it.

I've already filled my dataset (DsInfo) with a datatable ("RootInfo")

Dim cm As System.Windows.Forms.CurrencyManager
cm = Me.BindingContext(Me.DsInfo, "RootInfo")

The second line here is giving me a compile error:
C:\Projects\Code\Uniway\ServiceCenter\frmMain.vb(1082): Option Strict On
disallows implicit conversions from
'System.Windows.Forms.BindingManagerBase' to
'System.Windows.Forms.CurrencyManager'.

I've also tried to explicitly convert it using the CType function. It
compiles then, but has an unhandled exception. Any ideas?

Thanks,
Blake
 
Hi,

For there to be a BindingManagerBase/CurrencyManager you have to have bound
a control to the data soruce. If you have done performed the databinding,
could you supply the code you used to bind the control to the data source.

Hope this helps
 
Hi Blake,

You will have to use CType.
Are you sure that there is a DataTable name RootInfo in dataset?
What is the error when used with CType?
 
Ok, when you asked if I was sure there was a table named RootInfo, I went
and started checking around my code. I found some things that... well...
didn't quite look right but I don't fully understand why. My table name in
my DataSet is scRootInfo, but when I did my dataadapter.Fill, I used just
plain "RootInfo". I changed it to "scRootInfo" and changed all my
bindings/references and its working. Now, is there anyway you can clear up
for me, what the difference is? There's a table name in my database, a table
name in my dataset (these 2 are usually the same I assume) and then a
srcTable name that you use on .Fill calls. Whats the difference?

Thanks again,
Blake
 
Hi Blake,

Blake Weaver said:
Ok, when you asked if I was sure there was a table named RootInfo, I went
and started checking around my code. I found some things that... well...
didn't quite look right but I don't fully understand why. My table name in
my DataSet is scRootInfo, but when I did my dataadapter.Fill, I used just
plain "RootInfo". I changed it to "scRootInfo" and changed all my
bindings/references and its working. Now, is there anyway you can clear up
for me, what the difference is? There's a table name in my database, a table
name in my dataset (these 2 are usually the same I assume)

Not just usually :)

and then a
srcTable name that you use on .Fill calls. Whats the difference?

Src table is the name of the table within dataset to fill.
If such table does not exisist, it is created.
Note: instead you can fill directly the instance of datatable..Fill (table);
 
Back
Top