VS2013LEARNER
New member
- Joined
- May 5, 2022
- Messages
- 2
- Programming Experience
- Beginner
The following is the code but it is not showing any value though the data is available in MS Access Database.
VB.NET:
Private Sub cboMainCategory_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboMainCategory.SelectedIndexChanged
txtMainCategory.Text = cboMainCategory.Text
cboSubCategory.DataSource = Nothing
cboSubCategory.Items.Clear()
Call cboLoadSubCategory()
txtSubCategory.Select()
End Sub
Public Function cboLoadSubCategory()
If txtMainCategory.Text = "TILING" Then
Dim StrSql As String = "Select Category from SubCategories3Table"
ElseIf txtMainCategory.Text = "ELECTRIC CONNECTION" Then
Dim StrSql As String = "Select Category from SubCategories4Table"
ElseIf txtMainCategory.Text = "WATER CONNECTION" Then
Dim StrSql As String = "Select Category from SubCategories5Table"
Else
Dim StrSql As String = "Select Category from SubCategories1Table"
Dim dt As New DataTable
If Not DAL.ExecuteSql(dt, StrSql, Msg) Then MsgBox(Msg, MsgBoxStyle.Exclamation, "Error") : Return 0
Dim ds As New DataSet
ds.Tables.Add(dt)
cboSubCategory.ValueMember = "Category"
cboSubCategory.DataSource = ds.Tables(0)
If ds.Tables(0).Rows.Count > 0 Then
cboSubCategory.SelectedIndex = 0
End If
End If
Return True
End Function