Listbox populating problem

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I am populating a list box using the below code;

Dim MyResult As New DataTable
Dim MySQL As String = "SELECT <field list> FROM MyTable WHERE <some
condition> ORDER BY <some order> "
Dim MyAdapter As OleDbDataAdapter = New OleDbDataAdapter(MySQL,
DBConnection())
Dim MyDV As DataView

MyResult.Clear()
MyAdapter.Fill(MyResult)
MyDV = New DataView(MyResult)

MyDV.RowFilter = ""
Me.MyListbox.DataSource = MyDV.Table

The problem is the ListBox appears filled with 'System.Data.DataRowView'
appearing on each line instead of the actual data from table. What is the
problem and how can I fix it?

Thanks

Regards
 
John,

Set the displaymember and (as you use that) the valuemember of the listbox
to their columns (just a string)

Cor
 
Back
Top