VB.net MySQL如何在listview中放置两个表

时间:2016-01-31 12:00:26

标签: mysql vb.net listview

我想在列表视图中有两个表。我有项目和典当表。

项目表有类型(列)和 典当表有total_amount(列)

我希望这两列都出现在单个列表视图中

 con.Open()

    With cmd
        .Connection = con
        .CommandText = "SELECT pawn.total_amount, item.type FROM pawn INNER JOIN item ON pawn.pawn_id = item.pawn_id"

    End With
    dr = cmd.ExecuteReader
    ListView1.Items.Clear()
    While dr.Read
        With ListView1.ListItems.Add(, , dr("pawn_id"))
            .SubItems(1) = dr(UCase("type"))
            .SubItems(2) = dr(UCase("total_amount"))


        End With

    End While


    con.Close()

1 个答案:

答案 0 :(得分:0)

插入这个:

 Dim i as Integer = ListView1.Items.Count
 With ListView
 .items.Add(dr("pawn_id"))
 .items(i).subitems.add(dr("type"))
 .items(i).subitems.add(dr("total_amount"))
 End With