关于messagebox的问题
数据库里mBuilldingNo=2所对应的maintainerName有2个,如何让messagebox显示这两个值,现在只能显示一个,不知道为什么(进一步描述:一栋楼 有两个不同的维修人员,如何在确定这个楼号后,在messagebox里显示所有对应的maintainername) 如果在 listbox里显示两个maintainername,可以办到,但是messagebox却只能显示一个
string sql2 = "select * from [maintainer info] where mBuildingNo=2";
SqlCommand cmd2 = new SqlCommand(sql2, conn2);
SqlDataReader dr2 = cmd2.ExecuteReader();
listBox1.Items.Clear();
while (dr2.Read())
{
//if (dr2["mBuildingNo"].ToString() == "2")
MaintainerName = Convert.ToString(dr2["maintainerName"]);
//listBox1.Items.Add((string)dr2["maintainerName"]);
//comboBox1.Text = MaintainerName.ToString();
}
dr2.Close();
conn2.Close();
MessageBox.Show("Building No:2\n" + "\nBuilding Time:2009.2.17\n" + "\nRoom Size:100㎡\n" + "\nFloor:15\n" + "\nOwners Amount:" + ownernumber + "\n\nMaintainer Name:" + MaintainerName);
------解决方案--------------------string sql2 = "select * from [maintainer info] where mBuildingNo=2";
SqlCommand cmd2 = new SqlCommand(sql2, conn2);
SqlDataReader dr2 = cmd2.ExecuteReader();
while (dr2.Read())
{
MaintainerName += Convert.ToString(dr2["maintainerName"]);
}
dr2.Close();
conn2.Close();
MessageBox.Show("Building No:2\n" + "\nBuilding Time:2009.2.17\n" + "\nRoom Size:100㎡\n" + "\nFloor:15\n" + "\nOwners Amount:" + ownernumber + "\n\nMaintainer Name:" + MaintainerName);
------解决方案--------------------C# code
while (dr2.Read())
{
MaintainerName += Convert.ToString(dr2["maintainerName"])+"\n";
...................