'combobox Agent
Dim sql As String
Dim cdd As New BindingSource
'da.Fill(ds, "Agent")
sql = "SELECT * FROM Agent"
da = New SqlDataAdapter(sql, Conn)
da.Fill(ds, "Agent1")
cdd.DataSource = ds
cdd.DataMember = "Agent1"
With combobox1
.DataSource = cdd
.DisplayMember = "Agent_ID"
.BeginUpdate()
.ValueMember = "Agent_ID"
.EndUpdate()
End With
'combobox Agent
Dim sql As String
Dim cdd As New BindingSource
'da.Fill(ds, "Agent")
sql = "SELECT * FROM Agent"
da = New SqlDataAdapter(sql, Conn)
da.Fill(ds, "Agent1")
cdd.DataSource = ds
cdd.DataMember = "Agent1"
With combobox2
.DataSource = cdd
.DisplayMember = "Agent_Name"
.BeginUpdate()
.ValueMember = "Agent_ID"
.EndUpdate()
End With
Dim sql1 As String
Dim bs, bd As New BindingSource
Dim dt As New DataTable
sql1 = "SELECT * FROM Agent"
sql1 &= " WHERE Agent_ID = '" & combobox1.Text & "'"
da = New SqlDataAdapter(sql1, Conn)
Com = New SqlCommand()
With Com
.CommandText = sql1
.CommandType = CommandType.Text
.Connection = Conn
dr = .ExecuteReader()
If dr.HasRows Then
dt = New DataTable()
dt.Load(dr)
bs.DataSource = dt
combobox1.DataBindings.Clear()
combobox2.DataBindings.Clear()
combobox3.DataBindings.Clear()
combobox1.DataBindings.Add("SelectedValue", bs, "Agent_ID")
combobox2.DataBindings.Add("SelectedValue", bs, "Agent_Name")
combobox3.DataBindings.Add("SelectedValue", bs, "Department")
End If
End With
dr.Close()