Resolved [2005] Binded value shown for related table is WRONG when moving backward.
How can a person better troubleshoot why this is happening?
I tried looking at the BindingSource that is used for a control that doesn't have the problem (has blank results in the textbox when no results are returned), and it has a Count, position set, and Current datarow. I was expecting this to not have data, so that rules that out.
Is there any other code that a person should be running for related datasets after running a FillBy__ / Fill?
Or what area should I be examining to see the current linked value for a relation?
The value of Current for the main BindingSource is Nothing, but the BindingSources for everything else are set to the first value present in the datatable.
Last edited by wordracr; Oct 3rd, 2007 at 08:35 AM.
Re: [2005] When using FillBy_, related fields remain unchanged if no records are returned
Well, the FillBy method is not returning any rows for 1 table in question, but the textboxes that are databound to related tables still have data in them - I'd expect these textboxes to be blank.
Re: [2005] When using Fill, controls using related table fields have a value
Has anyone run into this issue when using multiple datatables that are related? I want to make the labels with related data show a blank value, but instead it shows the first occurrence of data from the datatable/database.
I've added an attachment with a sample using the sample SqlServer Pubs database connecting to localhost.
The problem was recreated there - if you go to the xsd and right click > configure on the sales datatable, then change the query to ... WHERE 1=0. The value of royaltyper will be 40. I'd expect this to be blank if no rows were returned.
Last edited by wordracr; Sep 24th, 2007 at 04:31 PM.
Re: [2005] When using Fill, controls using related table fields have a value
There is also another issue I'm having, and luckily, it's already present in the sample I've given.
Looking at record #1 (when the WHERE clause doesn't restrict), the title id/name field value is "The Busy Executive's Database Guide",
then going to #2 using the BindingNavigator's button, the title value is now "Is Anger the Enemy?"
Then back to record #1... the field value is still "Is Anger the Enemy?".
This seems like a bug - because generally, moving forward and backward does change the title field, but it is a bit.. off in position. Is there a method to call? I've tried this to no avail:
Code:
Private Sub SalesBindingSource_CurrentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalesBindingSource.CurrentChanged
TitlesBindingSource.ResetBindings(False)
End Sub
Re: [2005] When using Fill, controls using related table fields have a value
I don't know why no one downloaded the example - maybe the pubs database is not well known with sql2005?
I've redone another example in Adventure Works, reproducing the same 2 problems. Note: The #1 problem is now that the value shown for the lookup tables are wrong when doing the motion of moving: forward, forward, forward, back... (I even tried to make my custom functions to move the BindingSource, but that didn't change the behavior)
Note: the position of the ProductSubCategory is correct - just not the value shown.
Re: [2005] Binded value shown for related table is WRONG when moving backward.
Ok - here's the solution:
The combo box showing lookup values had the DataBinding Text property set to pretty much the same as DisplayMember. This should not have been done because of DataSource and Display/Value member being used.