0

I am trying to get a scoreboard to show up in my listbox from a mySQL DB.

However all i get in the list box is 'System.Data.DataRowView'

this is the code:

MySqlConnection myConn = new MySqlConnection(connStr);

string sqlStr = "SELECT CONCAT(Name, ' ', Score) as NameAndScore " + "FROM highscore ORDER BY Score DESC";

MySqlDataAdapter dAdapter = new MySqlDataAdapter(sqlStr, myConn);

DataTable dTable = new DataTable();
lstNames.DisplayMember = "NameAndScore";
lstNames.DataSource = dTable;
dAdapter.Fill(dTable);
dAdapter.Dispose();
Agustin Meriles
  • 4,866
  • 3
  • 29
  • 44
Cain Neal
  • 197
  • 2
  • 4
  • 15

1 Answers1

0

Fill before binding.

 dAdapter.Fill(dTable);
 lstNames.DataSource = dTable;
 lstNames.DisplayMember = "NameAndScore";
Hamlet Hakobyan
  • 32,965
  • 6
  • 52
  • 68