enter image description here我試圖在組合框中顯示所有項目,但是當我運行我的應用程序時,我只能獲得一個項目。你能不能幫我請,這裏是我的代碼爲什麼我的組合框只顯示一個項目? c#mysql
try
{
MySqlConnection conection = new MySqlConnection("server = 127.0.0.1; database = sistemalaboratorio; Uid = root; pwd =;");
string selectQuery = "SELECT clavemateria FROM materia";
conection.Open();
MySqlCommand command = new MySqlCommand(selectQuery, conection);
MySqlDataReader reader = command.ExecuteReader();
while (reader.Read());
{
comboBox1.Items.Add(reader["clavemateria"].ToString());
}
} catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
查詢的結果是什麼? –
我只得到我的查詢的最後結果。 –
嘗試使用'SELECT COUNT(*)clavemateria FROM materia'運行它 – user5226582