Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ADO.NET C#4.0 Access
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
           fnGetDataBindingForTextBoxes();
                     fnSetCurrencyManager();
           //Record numbers in the StatusBar
           fnDisplayRecordNumbers();
       }
       else
       {
           MessageBox.Show("Connection failed...");
           Application.Exit(); 
       }
   }
Posted 18-Sep-12 20:12pm
Edited 18-Sep-12 20:40pm
v2
Comments
arshad alam at 19-Sep-12 2:15am
   
can you share your code and error snapshot with us ?
mhassan083 at 19-Sep-12 2:43am
   
the text of error message is exist

1 solution

Rate this: bad
good
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.Clear();
Me.TextBox1.DataBindings.Add("Text", myDataTable, "Col1Name")
  Permalink  
Comments
mhassan083 at 19-Sep-12 2:52am
   
now, code shared
Sandeep Mewara at 19-Sep-12 3:18am
   
Try to put:
this.dataGrid1.DataBindings.Clear();
 
before assigning datasource. See if it helps.
mhassan083 at 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 at 19-Sep-12 3:36am
   
???
 

Not clear. New issue?
mhassan083 at 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 at 19-Sep-12 3:57am
   
Then you need to clear/reset that too!
mhassan083 at 19-Sep-12 4:11am
   
i'm trying to pass the same code but fail with statusbarpanel
mhassan083 at 19-Sep-12 4:34am
   
now,i'm trying this and success with me
( this.statusBarPanel1.Text = " ";)
Sandeep Mewara at 19-Sep-12 4:56am
   
Good to now!
:thumbsup:

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

  Print Answers RSS
0 George Jonsson 359
1 Sergey Alexandrovich Kryukov 355
2 CPallini 335
3 BillWoodruff 324
4 OriginalGriff 237
0 OriginalGriff 5,050
1 CPallini 4,225
2 Sergey Alexandrovich Kryukov 3,639
3 George Jonsson 2,911
4 Gihan Liyanage 2,386


Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 19 Sep 2012
Copyright © CodeProject, 1999-2014
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