Public Sub FiltercmbSubCategory()
Dim sqlconn As New SqlClient.SqlConnection
sqlconn.ConnectionString = "server = SKPI-APPS1;" & _
"Database = EOEMS;integrated security=true"
Dim sqlcommand As SqlCommand
sqlconn.Open()
Dim da As New SqlDataAdapter("SELECT * FROM tblOfficeEquipmentSubCategory WHERE SUBCAT_ID = '" & cmbCategory.Text & "'", sqlconn)
Dim dt As New DataTable
da.Fill(dt)
cmbCategory.DataSource = dt
cmbCategory.DisplayMember = "SUBCAT_Name"
cmbCategory.ValueMember = "SUBCAT_ID"
sqlconn.Close()
End Sub
当我将此代码放在表单加载事件上时,当我将此代码放在第一个组合框的 index_changed 上时,第一个组合框上的数据也会消失
但是当我评论这段代码时,它会在组合框 1 中再次显示记录
我需要根据 CATEGORY_COMBOBOX 过滤 SUB_CATEGORY_COMBO_BOX