Rick_Fla
Well-known member
Ok, I am having a wierd issue I can not seem to resolve. I have a Sub (code below) that fills a datatable, which inturn is the datasource of a combobox. I have a MAIN and SUB combobox. So when I change the MAIN combobox, on its selectindexchange event, I call the code below to change the information in the datatable for the SUB combobox. Pretty simple.
The issue is when I first run the program and select a main category, there is a pause at the oAdapter.Fill(oSubCategoryTB) command of maybe 1-2 seconds. Which makes the application seem to freeze. But I get the correct results after that pause. Any other calls show no pause at all. This only seems to appear when I use the .cler method on the Datatable, which I must use or I get duplicates in the SUB combobox. Is there something I am missing? if you need more infor please let me know.
The issue is when I first run the program and select a main category, there is a pause at the oAdapter.Fill(oSubCategoryTB) command of maybe 1-2 seconds. Which makes the application seem to freeze. But I get the correct results after that pause. Any other calls show no pause at all. This only seems to appear when I use the .cler method on the Datatable, which I must use or I get duplicates in the SUB combobox. Is there something I am missing? if you need more infor please let me know.
Code:
Private Sub CategoryList(ByVal Id As Integer, ByVal Type As CategoryType)
Variables
Dim sSQL As String = "SELECT * FROM Categories WHERE SubCategoryID = " & Id & ""
Try
Fill DataSet
oAdapter = New OleDbDataAdapter(sSQL, sConnectionString)
Fill Correct DataSet
Select Case Type
Case CategoryType.MainCategory
oAdapter.Fill(oMainCategoryTB)
Case CategoryType.SubCategory
oSubCategoryTB.Clear()
oAdapter.Fill(oSubCategoryTB)
End Select
Dispose
oAdapter.Dispose()
sSQL = Nothing
Catch ex As Exception
MessageBox.Show(ex.ToString, "Error - CategoryList")
End Try
End Sub