I am getting a multiple bindings error...

EStallworth

Well-known member
Joined
Aug 14, 2006
Messages
75
Location
Destin, FL
Programming Experience
Beginner
I am having trouble binding more than one object within a select case statement and do not quite understand why. I have read the post above for a similar problem, but need it explained as it seems to me that Paszt is using an array and I do not understand why. I am trying to bind several labels to certain values in a dataset based on a certain months data. It seems redundant to have to clear the bindings before I assign more. Can anyone help me understand the error?¿

Here is the error I am receiving.

"This causes two bindings in the collection to bind to the same property.
Parameter name: binding"

VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] month [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Char[/COLOR][/SIZE]
[SIZE=2]month = duedatelabel.SelectedValue[/SIZE]
 
[SIZE=2][COLOR=#0000ff]Select[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2] month[/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000]"January"[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000]"February"[/COLOR][/SIZE]
[SIZE=2]SqlDataAdapter6.SelectCommand.Parameters([/SIZE][SIZE=2][COLOR=#800000]"@Param1"[/COLOR][/SIZE][SIZE=2]).Value = ComboBox1.SelectedValue[/SIZE]
[SIZE=2]SqlDataAdapter6.Fill(DataSet331)[/SIZE]
[SIZE=2]previousadjustlabel.DataBindings.Add([/SIZE][SIZE=2][COLOR=#800000]"Text"[/COLOR][/SIZE][SIZE=2], DataSet331, [/SIZE][SIZE=2][COLOR=#800000]"January1.Unpaid Adjustments"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]previouscollectionlabel.DataBindings.Add([/SIZE][SIZE=2][COLOR=#800000]"Text"[/COLOR][/SIZE][SIZE=2], DataSet331, [/SIZE][SIZE=2][COLOR=#800000]"January1.Unpaid Collection"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000]"March"[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000]"April"[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000]"May"[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000]"June"[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000]"July"[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000]"August"[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000]"September"[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000]"October"[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000]"November"[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000]"December"[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Select[/COLOR][/SIZE]
 
Last edited by a moderator:
The error message is in quotes before the code block. I copied it just as it was. :)
 
previousadjustlabel.DataBindings.Add("Text", DataSet331, "January1.Unpaid Adjustments")
previouscollectionlabel.DataBindings.Add("Text", DataSet331, "January1.Unpaid Collection")


Well, your problem is obviously in the above lines. I'd remove the spaces from the bit's i've highlighted. But seeing as the binding collection doesn't get cleared and it could be changed at the click of a combobox. I'd suggest clearing the bindings before attempting more.
 
Are the datatables you are binding, different shapes?

e.g. does July's table have a different shape to June's table?
 
Then why not either selectively fill a datatable, or fill a datatable with everything and have the viewing components filter it?


e.g. have a MonthsData datatable, and controls are bound to it. have the tableadapter contain a query such as:

SELECT * FROM MonthDataInDatabase WHERE monthname = @monthname

The tableadapter would thus be created with a parameter, and your case statement would become moot like:

VB.NET:
[COLOR=#0000ff]Dim[/COLOR][SIZE=2] month [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Char[/COLOR][/SIZE]
[SIZE=2]month = duedatelabel.SelectedValue[/SIZE]
 
[SIZE=2][COLOR=#0000ff]Select[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2] month[/SIZE]
[SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2][COLOR=#800000]"January"[/COLOR][/SIZE]

VB.NET:
[COLOR=#0000ff]monthsTableAdapter.Fill(monthsDataTable, [/COLOR][COLOR=#000000]duedatelabel.SelectedValue)
[/COLOR][COLOR=#800000]
[/COLOR]

do note that you declare month as Char, yet you try and put a string into it, or test it against a string..

To better explain it, it would help for me to see your project. Looking at the code so far, I'd say that youre possibly making some things a lot harder for yourself than you need to. If you do choose to post a project to the forum, you should remove all EXEs from it first by choosing Clean from Project menu
 
Back
Top