Hi all !I've customized a UltraDataSource (please have a look at the code at the end of this post). The data source should be filled with a larage amount of data rows (>200000) taken from database.The filling from database will be started by invoking the FillData(..) method. The datasource rows will be added by this.Rows.Add(
new object[{
reader[SQL.SQL_V_Kunde.COLUMN_FINR],
reader[SQL.SQL_V_Kunde.COLUMN_KDNR]
});The values for columns SQL.SQL_V_Kunde.COLUMN_FINR and SQL.SQL_V_Kunde.COLUMN_KDNR are simple integer values.Filling the datasource in that way will lasts about 5. minutes and slows down my application extremely.Instead loading those values into a simple ArrayList collection (in the same method) lasts only seconds. Object obj1 = reader[SQL.SQL_V_Kunde.COLUMN_FINR]; Object obj2 = reader[SQL.SQL_V_Kunde.COLUMN_KDNR]; alist.Add(new object[ { obj1, obj2 });
Any advice or ideas you might have, would be very welcome. Thanks in advance !
Kind regards,
Claus
[Serializable] public partial class CustomerDataSource : UltraDataSource { public CustomerDataSource():base() { InitializeComponent(); InitSchema(new DataSourceSchemaCustomer()); AddEmptyRow(); } ....
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] public new Infragistics.Win.UltraWinDataSource.UltraDataBand Band { get { return base.Band; } } [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] public new Infragistics.Win.UltraWinDataSource.UltraDataRowsCollection Rows { get { return base.Rows; } } public void FillData(String sqlQuery, ref int i) { OracleConnection connection = null; OracleCommand cmd = null; OracleDataReader reader = null; if (this.Filled == false) { try { connection = new OracleConnection(Config.DataBaseConfiguration.GetDatabaseConfigurationString()); cmd = connection.CreateCommand(); cmd.CommandText = sqlQuery; connection.Open(); reader = cmd.ExecuteReader(); while (reader.Read()) { if (reader[SQL.SQL_V_Kunde.COLUMN_KDNR] != System.DBNull.Value) { this.Rows.Add(new object[{ reader[SQL.SQL_V_Kunde.COLUMN_FINR], reader[SQL.SQL_V_Kunde.COLUMN_KDNR] }); i++; } } this.Filled = true; } catch (Exception e) { Console.WriteLine(e.StackTrace); } finally { try { if (reader != null) { reader.Close(); reader = null; } if (connection != null) { connection.Close(); connection = null; } } catch (Exception e) { Console.WriteLine(e.StackTrace); } } } }
Hi Claus,
Try using a different overload that bypasses raising notifications. Also enclose the entire while loop inside SuspendBindingNotifications and ResumeBindingNotifications to prevent any individual per row binding related notifications being set while rows are being added. ResumeBindingNotifications will instead send a reset notification so bound controls will still reflect new data properly.
// Use this overload that bypasses raising events
this.Rows.Add( false, new object[{ reader[SQL.SQL_V_Kunde.COLUMN_FINR], reader[SQL.SQL_V_Kunde.COLUMN_KDNR] }, false );
Hope this helps,
Sandip
What version are you using? Do you have the latest Hot Fix?
Are there controls bound to the UltraDataSource at the point where you are adding rows? If so, those controls will all receive notifications of the new row and may be slowing things down by updating themselves. An ArrayList would not have this problem. So you might try not binding the controls unilt after the UDS has been completely populated.