filter combobox based on another combobox vb.net (1 Viewer)

spider2vb

New member
Local time
Today, 16:06
Joined
Sep 22, 2011
Messages
2
Hi ,,
i have problem with combobox
i have two combobox and two tables

table manages (ManageID, ManageName)
table Departments (DeptID, DeptName, Dept_ManageID)

1- CboEmp_Manage
2- CboEmp_Dept



Public Class Class1
Public sub FillCombobox (ByVal cbo As Combobox, ByVal TableName As String , ByVal Col_name As String , ByVal Col_Value As String , ByVal KKR As String)
Try
Dim VarSql As String
VarSql = ""
VarSql = "Select " + Col_name + " , " + Col_Value + " From " + TableName + " " + KKR
Dim sda As New SqlDataAdapter(VarSql , SQLCon)
Dim ds As New Dataset ()
sda.Fill(ds)
cbo.DataSource = ds.Tables(0)
cbo.DisplayMember = Col_name
cbo.ValueMember = Col_Value
Catch

End Try

End Sub

Private Sub CboEmp_Manage_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CboEmp_Manage.SelectedValueChanged

WinClass.FillCombobox (CboEmp_Dept, "Departments WHERE Dept_Manage_ID LIKE '%" & CboEmp_Manage.SelecteIndex.ToString() & "%' " , "Dept_Name", "Dept_ID", "")

End Sub

give me wrong data from table
 

Users who are viewing this thread

Top Bottom