Fill datasource what are binded to control what located on different form!!!
-
Hi all. In my application i have one data table what can be binded to control on one form and can be filled on another form.
this.cLIENTBindingSource.DataSource = this.dataSet1.CLIENT; .... this.comboBox1.DataSource = this.cLIENTBindingSource;
In proper moment i press a button to make refilling of CLIENT data table.private void simpleButton1_Click(object sender, EventArgs e) { this.cLIENTTableAdapter.Fill(this.dataSet1.CLIENT); }
In this case all work fine! :-D But when i bind this data table to control on one form and fill this one on other form like this: Form 1:this.cLIENTBindingSource.DataSource = this.dataSet1.CLIENT; .... this.comboBox1.DataSource = this.cLIENTBindingSource; .... private void simpleButton1_Click(object sender, EventArgs e) { Form2 form2 = new Form2(); Form2.Show(this.cLIENTTableAdapter, this.dataSet1.CLIENT) }
Form 2:private void simpleButton1_Click(object sender, EventArgs e) { _dataAdapter.Fill(_dataTable); } internal void ShowDialog(System.Data.Common.DbDataAdapter DataAdapter, System.Data.DataTable DataTable, System.Windows.Forms.BindingSource BindingSource) { _dataAdapter = DataAdapter; _dataTable = DataTable; this.ShowDialog(); }
In this case all sad. :(( Fill is make vary slow and even may fail. Where is problem here and what i can do to resolve it??? THANK -
Hi all. In my application i have one data table what can be binded to control on one form and can be filled on another form.
this.cLIENTBindingSource.DataSource = this.dataSet1.CLIENT; .... this.comboBox1.DataSource = this.cLIENTBindingSource;
In proper moment i press a button to make refilling of CLIENT data table.private void simpleButton1_Click(object sender, EventArgs e) { this.cLIENTTableAdapter.Fill(this.dataSet1.CLIENT); }
In this case all work fine! :-D But when i bind this data table to control on one form and fill this one on other form like this: Form 1:this.cLIENTBindingSource.DataSource = this.dataSet1.CLIENT; .... this.comboBox1.DataSource = this.cLIENTBindingSource; .... private void simpleButton1_Click(object sender, EventArgs e) { Form2 form2 = new Form2(); Form2.Show(this.cLIENTTableAdapter, this.dataSet1.CLIENT) }
Form 2:private void simpleButton1_Click(object sender, EventArgs e) { _dataAdapter.Fill(_dataTable); } internal void ShowDialog(System.Data.Common.DbDataAdapter DataAdapter, System.Data.DataTable DataTable, System.Windows.Forms.BindingSource BindingSource) { _dataAdapter = DataAdapter; _dataTable = DataTable; this.ShowDialog(); }
In this case all sad. :(( Fill is make vary slow and even may fail. Where is problem here and what i can do to resolve it??? THANKThis doesn't quite make sense. In case 1 you fill dataset and in case 2 you fill datatable. Also in case 2 the code is executed based on user input (button click) so it's not immediate. Perhaps you should explain a little bit more what you are trying to achieve.
The need to optimize rises from a bad design. My articles[^]
-
This doesn't quite make sense. In case 1 you fill dataset and in case 2 you fill datatable. Also in case 2 the code is executed based on user input (button click) so it's not immediate. Perhaps you should explain a little bit more what you are trying to achieve.
The need to optimize rises from a bad design. My articles[^]
This just a sample. Actually i use one static dataset in my application and can display in two diffrent windows forms (suppose parent and child) same data table in the same time, all work fine, till i start to fill this data table in one form, in this case Fill operation are maked very slow. But when i use so one form and fill data table exatamente in it all work fine. Example above just describe this situation.
-
This just a sample. Actually i use one static dataset in my application and can display in two diffrent windows forms (suppose parent and child) same data table in the same time, all work fine, till i start to fill this data table in one form, in this case Fill operation are maked very slow. But when i use so one form and fill data table exatamente in it all work fine. Example above just describe this situation.
There could be two reasons. Either the statement used for fill is slow or the existing binding is making it slow. Before filling the dataset, remove any bindings to it and rebind after the fill. Perhaps that would help.
The need to optimize rises from a bad design. My articles[^]
-
There could be two reasons. Either the statement used for fill is slow or the existing binding is making it slow. Before filling the dataset, remove any bindings to it and rebind after the fill. Perhaps that would help.
The need to optimize rises from a bad design. My articles[^]
Yes its a solution. But why when i fill this table in the same form where binded my control (either without rebinding) all work fine, but when in another all work very slow????? Thats the Point.
modified on Monday, October 27, 2008 3:52 AM
-
Yes its a solution. But why when i fill this table in the same form where binded my control (either without rebinding) all work fine, but when in another all work very slow????? Thats the Point.
modified on Monday, October 27, 2008 3:52 AM
As I said in the first post, the scenarios are not the same. In your first example you fill the dataset. So it seems that you don't have a datatable in the dataset, but it's created during fill. In the second example, you already have a datatable and you're filling it. So it makes me wonder if you have existing event handlers, binding etc. attached to the datatable. If so, they can be the cause to the slow fill. Especially if binding is involved since existing binded objects must be refreshed when binding is done. This wouldn't be the case in example 1. Without seeing the actual situation, it's merely guessing. However, the filling speed should be equal in both cases if the query is the same and the 'surroundings' are the same (eventhandlers etc)
The need to optimize rises from a bad design. My articles[^]