Hi
I have access database called "DB" and Table Name is "Empdata" and following by details in colomn
ID Name Day Amount
1 Mani Monday 50
2 Subash Tuesday 100
3 Mani Tuesday 100
4 subash Mondy 50
5 Mani Wednesday 100
6 Subash Wednesday 50
7 Mani Thursday 100
8 Mani Friday 10
9 Mani Saturday 30
10 Subash Saturday 20
11 Subash Sunday 100
in vb.net i have Datagridview1 name as "dg1" and loaded with datasource
combobox1 name as "compbo"
1. i want to fill the Name in compbo
2.i want to use combobox(compbo) to filter data from Datagridview1 (dg1)
3. everything is showed correct but combobox showing same name multiple (ofcouse column having same but it should show same name in one name) for ex. Mani should show only one name if i filter that all the Mani details should show
4. And finally filter in the datagridview not working
What I have tried:
Public Sub LD()
ConnD()
sql = "select ID,Name,Day,Amount from Empdata"
cmd = New OleDbCommand(sql, conn)
da = New OleDbDataAdapter(sql, conn)
da.Fill(dt)
bs.DataSource = dt
dr = cmd.ExecuteReader()
dg1.DataSource = bs
End Sub
Public Sub fillcombo()
ConnD()
Try
sql = "select distinct ID,Name,Day,Amount FROM Empdata "
cmd = New OleDbCommand(sql, conn)
da = New OleDbDataAdapter(sql, conn)
da.Fill(dt)
bs.DataSource = dt
dr = cmd.ExecuteReader()
compbo.Items.Clear()
dg1.DataSource = dt
Do While dr.Read
compbo.Items.Add(dr.GetValue(1).ToString)
Loop
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
conn.Close()
conn.Dispose()
conn = Nothing
End Sub
End Class