Fill in Textboxes from a Dataset

Dim CON As New SqlClient.SqlConnection
CON.ConnectionString = “integrated security=SSPI;data source=SERVER1;persist security info=False;initial catalog=filmtrack”

    Dim ds As New DataSet 
    Dim da As New SqlClient.SqlDataAdapter("SELECT JobNo, BoxNo,PartJob FROM JobTab WHERE JobNo LIKE '%" & TextBox1.Text & "%'", CON) 

    ds.Clear() 
    CON.Open() 

da.Fill(ds)

If ds.Tables(0).Rows.Count >0 Then
TextBox2.Text = ds.Tables(0).Rows(0)(“PartJob”)
TextBox3.Text = ds.Tables(0).Rows(0)(“BoxNo”)
End If

You could also do the following:
This number is to select 1 row. For example when you put a value in textbox is just 1 values. So you choose the row number and take from there.

If you want to bind a listbox or a combobox to a dataset you dont have to do it.
You can do that 2 ways:

1 -automatic

listbox1.DataSource = ds.tablename
listbox1.DisplayMember = “columnname”

2 - loop the dataset

Dim i as Integer
For i = 0 to ds.tablename.Rows.Count -1
ListBox1.Items.Add(ds.tablename.Rows(i)(“columnname”))
Next

Once you filled the dataset you do the event handle:

Private Sub ListBox1_SelectedvalueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedValueChanged
TextBox1.Text = ListBox1.SelectedText
End Sub