listbox is empty我想从我的SQL中获取数据并将其插入到列表框表单中,但我不能。通过编译列表框为空。我怎么了?
private: System::Void listBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e)
{
String^ SQLconnection = "Server = localehost; Uid = root; Password = pass123; Database = details";
MySqlConnection^ conn = gcnew MySqlConnection(SQLconnection);
MySqlCommand^ cmd = gcnew MySqlCommand("SELECT * FROM details.material;", conn);
MySqlDataReader^ reader;
try
{
conn->Open();
reader = cmd->ExecuteReader();
while (reader->Read())
{
listBox1->Text +=(reader->GetInt32(0));
}
}catch (Exception^ ex)
{
MessageBox::Show(ex->Message);
}
}