我正在尝试使用以下代码在lblTrailerNo标签中显示ICDTmpTrailerMovemnt表中的所有TrailerNo。但是它多次显示第一行值但是我如何获取该特定列的所有行,如
CMDHA-610023 CMDHA-610024 CMDHA-610026 CMDHA-610027 CMDHA-610028 CMDHA-610029 CMDHA-610030 CMDHA-610031等
String con = dbcon;
String SQL = "select TrailerNo from ICDTmpTrailerMovemnt";
SqlDataAdapter Adpt = new SqlDataAdapter(SQL, con);
DataSet ds = new DataSet();
Adpt.Fill(ds);
foreach (DataRow dr in ds.Tables[0].Rows)
{
lblTrailerNo.Text += ds.Tables[0].Rows[0]["TrailerNo"].ToString() + "<br />";
}
答案 0 :(得分:3)
foreach (DataRow dr in ds.Tables[0].Rows)
{
lblTrailerNo.Text += dr["TrailerNo"].ToString() + "<br />";
}