Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System.Data.datarowview error when populating listbox. Pls help me..;(

Status
Not open for further replies.

shaunieb

Programmer
Sep 2, 2004
26
ZA
hI, I'm mailny a asp.net guy and its pretty straight forward to do this with dropdownboxes etc is asp.net but for the life of me i'm striggling in vs to populate my listbox. I get System.Data.Datarowview instead of the values from my request. Please help. I've tried to do this for about 4 hrs and i'm sure im missimg something really small.
:)

Private Sub tables_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles tables.SelectedIndexChanged
data = New DataTable
da = New MySqlDataAdapter("SELECT id FROM Company", conn)
cb = New MySqlCommandBuilder(da)

Dim ds As DataSet = New DataSet
da.Fill(ds, "Company")

Dim dv As DataView = ds.Tables("Company").DefaultView
ListBox1.DisplayMember = "Id"
ListBox1.DataSource = dv

End Sub
 
Try setting the listbox's datasource before setting the displaymember:

ListBox1.DataSource = dv
ListBox1.DisplayMember = "Id"


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
HI, thanks 4 the the help! still doesnt work...
 
Enter break mode after you fill the DataSet and verify that the Company table contains a column named Id. If it does, make certain that your DisplayMember matches the same case.
 
put the cursor on a line after the ".datasource =" and press "F9"

if you run the app in "DEBUG" mode (the combo box at the top of the screen) it will stop at the "Break Point" and you can use the immediate window, or command window to view the contents of the listbox.datasource.

-Rick

----------------------

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
i got it, just looping through the dataset and populating row by row. thnks everyone
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top