Bindingsource problem

  • Thread starter Thread starter Flomo Togba Kwele
  • Start date Start date
F

Flomo Togba Kwele

Why would the first statement execute fine, but the second errors out? How can this be?
The first line is in the Load event, the second in a button event. The error message
follows the second line.

Also, aBindingSource.SupportsSearching is True.

TextBox1.DataBindings.Add("Text", aBindingSource, "FK_Name.DataMemberA", True)

dim position as Integer = aBindingSource.Find("FK_Name.DataMemberA", 3)
(Message="DataMember property 'FK_Name.DataMemberA' cannot be found on the DataSource.")
 
The Find method is expecting the name of a property and will not parse
the parameter like the Add method does. Try just passing in DataMemberA
for the call to Find.
 
Thanks for the hint, Bryan. I tried it and the results were the same.

I did not mention the environment. The bindingsource is bound to a dataset and
a master table as datamember. There is also a child table and a relation
"FK_Name". According to the Find documentation:

returnValue = instance.Find(propertyName, key)
where instance is a BindingSource and returnValue is an integer.

I still don't see why it shouldn't work.

dim position as Integer = aBindingSource.Find("FK_Name.DataMemberA", 3)

FK_Name.DataMemberA is a property name and 3 is the key.

If I just use DataMemberA as the property name, it is not in the master table,
but it is in the child table.

Any other suggestions?
 
Hi Flomo,

I performed a test based on your description and did reproduce the problem
on my side.

The Find method of the BindingSource requires the properties in the data
source. In your scenario, these properties are the columns in the master
table, not including the columns in the child table.

To find the item in the child table, we could create a BindingSource
instance for the child datatable and then call the Find method of the
BindingSource.

The following is a sample.

Dim bBindingSource As New BindingSource(dataset, "child table")
bBindingSource.Find("DataMemberA",3)

Hope this helps.
If you have any question, please feel free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top