Click here to Skip to main content
12,998,654 members (130,336 online)
Rate this:
Please Sign up or sign in to vote.
Hii, everybody,
when click button to display data in datagridview and textboxes data show with no problem ,but when click again this message appear and project need to close

this error message :

this causes two bindings in the collection to bind to the same property.
parameter name:binding.

this is my code :
//check the connection to database
       if (this.datc.fnGetDataConnection())
            this.dataGrid1.ReadOnly = true;
           this.dataGrid1.DataSource = datc.dSet.Tables["student"];
           // DataBinding of TextBoxes
           //Record numbers in the StatusBar
           MessageBox.Show("Connection failed...");
Posted 18-Sep-12 20:12pm
Updated 18-Sep-12 20:40pm
arshad alam 19-Sep-12 2:15am
can you share your code and error snapshot with us ?
mhassan083 19-Sep-12 2:43am
the text of error message is exist

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Since you have not shared your code, based on what you say, it sounds like you call the same code more than once in your program to reload your data source - as a result, the code is calling Control.DataBindings.Add twice with the same parameters. This would attempt to add a duplicate binding to the DataBindings collection - leading to error.

One solution is to clear the DataBindings collection before you add your new binding, something like:
Me.TextBox1.DataBindings.Add("Text", myDataTable, "Col1Name")
mhassan083 19-Sep-12 2:52am
now, code shared
Sandeep Mewara 19-Sep-12 3:18am
Try to put:

before assigning datasource. See if it helps.
mhassan083 19-Sep-12 3:31am
i do that in textboxes and success in the same time message does not appear but
satus bar repeated data on status bar???
Sandeep Mewara 19-Sep-12 3:36am

Not clear. New issue?
mhassan083 19-Sep-12 3:46am
i mean when click again data on staus bar on the form duplicated after each click
(1 of record 1 one of record 1 one of record 1....)
Sandeep Mewara 19-Sep-12 3:57am
Then you need to clear/reset that too!
mhassan083 19-Sep-12 4:11am
i'm trying to pass the same code but fail with statusbarpanel
mhassan083 19-Sep-12 4:34am
now,i'm trying this and success with me
( this.statusBarPanel1.Text = " ";)
Sandeep Mewara 19-Sep-12 4:56am
Good to now!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170622.1 | Last Updated 19 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100