0

我正在尝试让记分牌从 mySQL DB 显示在我的列表框中。

但是我在列表框中得到的只是'System.Data.DataRowView'

这是代码:

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();
4

1 回答 1

0

装订前填充。

 dAdapter.Fill(dTable);
 lstNames.DataSource = dTable;
 lstNames.DisplayMember = "NameAndScore";
于 2013-03-14T22:38:46.140 回答