|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Slow form load when Databinding a WinformI am using ODP for .Net to build a multi-table dataset. The problem I am running into is when I load the ZIP code table (42,741 records) into the dataset and databind it to a combobox. Try ' Fill the ZIP Code data table. Dim da As New OracleDataAdapter, dr As OracleDataReader Dim cmd As New OracleCommand("PACK_ZIP_CODES.ZIP_CODES", conORA) With cmd .CommandType = CommandType.StoredProcedure .Parameters.Add(New OracleParameter("o_RESULT_SET", OracleDbType.RefCursor, ParameterDirection.Output)) .Connection = conORA End With With da .SelectCommand = cmd .Fill(dsMulti, "ZIP_CODES") .Fill(dsMulti, "E_ZIP_CODES") End With cmd.Dispose() da.Dispose() Catch ex As OracleException Cursor.Current = Cursors.Default MsgBox(ex.Message) End Try The form paints extremely slow. When I click on the tab that contains the combobox, it also paints extremely slow. When I skip loading the ZIP Code table into the dataset, the form loads quickly. When I create a datareader based on the same ZIP Code table and load the combobox, the form also paints very quick. Dim cmdZIPS As New OracleCommand("PACK_ZIP_CODES.ZIP_CODES", conORA) Dim drZIPs As OracleDataReader With cmdZIPS .CommandType = CommandType.StoredProcedure .Parameters.Add(New OracleParameter("o_RESULT_SET", OracleDbType.RefCursor, ParameterDirection.Output)) .Connection = conORA End With conORA.Open() drZIPs = cmdZIPS.ExecuteReader(CommandBehavior.CloseConnection) If drZIPs.HasRows Then Do While drZIPs.Read() cboH_ZIP_Code.Items.Add(drZIPs("ZIP_CODE")) cboH_ZIP_Code.Tag = (drZIPs("CITY")) cboE_ZIP_Code.Items.Add(drZIPs("ZIP_CODE")) cboE_ZIP_Code.Tag = (drZIPs("CITY")) Loop End If drZIPs.Close() Unfortunately, the datareader can not be databound to the combobox. I need to be able to: 1. Load the combobox quickly 2 Databind the combobox to the dataset Does anybody out there have a solution? Thanks in afvance. Vince Dalton "Vincent Dalton" <vi***@ec.rr.com> wrote in message Not sure exactly what you mean by not being able to databind using a news:IISef.1243$3o6.516440@twister.southeast.rr.com... > Unfortunately, the datareader can not be databound to the combobox. I need > to be able to: > 1. Load the combobox quickly > 2 Databind the combobox to the dataset > > Does anybody out there have a solution? datareader. But here is some code that may help... ..... cboH_ZIP_Code.BeginUpdate() Do While dbDR.Read cboH_ZIP_Code.Items.Add(New ListBoxItem(drZIPs("CITY").ToString, drZIPs("ZIP_CODE").ToString)) Loop cboH_ZIP_Code.EndUpdate() ..... Public Class ListBoxItem Private listItemData As Object Private listItemText As String ' This is what is displayed in the ComboBox drop-down Public Overrides Function ToString() As String Return listItemText End Function Public Sub New(ByVal itemData As Object, ByVal itemText As String) listItemData = itemData listItemText = itemText End Sub Public ReadOnly Property Data() As Object Get Data = listItemData End Get End Property Public ReadOnly Property Text() As String Get Text = listItemText End Get End Property End Class Greg Greg,
I have the combobox loading quickly now. I am having an issue with the actual databound records. To summarize, I have a table, CONTACTS, loaded into a dataset with 104 records. I have another table, ZIP_CODES, with 40,000+ records. The ZIP Codes are loaded into a combobox, which is databound. It takes forever to load the form, to move from record to record, or update a record. If I remove the binding from the ZIP_CODE table, the problem is gone. This defeats the purpose, though, as the record is no longer bound. Do you know of a way I could speed up the form/dataset? Thanks, Vince Show quote >> Unfortunately, the datareader can not be databound to the combobox. I >> need to be able to: >> 1. Load the combobox quickly >> 2 Databind the combobox to the dataset >> >> Does anybody out there have a solution? > > Not sure exactly what you mean by not being able to databind using a > datareader. But here is some code that may help... > > .... > cboH_ZIP_Code.BeginUpdate() > Do While dbDR.Read > cboH_ZIP_Code.Items.Add(New ListBoxItem(drZIPs("CITY").ToString, > drZIPs("ZIP_CODE").ToString)) > Loop > cboH_ZIP_Code.EndUpdate() > .... > > > Public Class ListBoxItem > > Private listItemData As Object > Private listItemText As String > > ' This is what is displayed in the ComboBox drop-down > Public Overrides Function ToString() As String > Return listItemText > End Function > > Public Sub New(ByVal itemData As Object, ByVal itemText As String) > > listItemData = itemData > listItemText = itemText > End Sub > > Public ReadOnly Property Data() As Object > Get > Data = listItemData > End Get > > End Property > > Public ReadOnly Property Text() As String > Get > Text = listItemText > End Get > > End Property > > End Class > > Greg > > |
|||||||||||||||||||||||