0
   Dim dr As SqlDataReader = cmd.ExecuteReader

      Me.ListView1.Items.Clear()
      Do While dr.Read

        With Me.ListView1
            .Items.Add(dr(0))
            With .Items(.Items.Count - 1).SubItems
                .Add(dr.Item(1))
                .Add(dr.Item(2))
                .Add(dr.Item(3))
        End With
             End With
    Loop
    dr.Close()


   Me.Show()

    Me.ListView1.Columns.Add("Account ID", 100)
    Me.ListView1.Columns.Add("Managed by", 100)
    Me.ListView1.Columns.Add("Account Holder", 100)
    Me.ListView1.Columns.Add("Description", 100)

'Public Function Add(text As String)As System.Windows.Forms.Listviewitem.Listview.Subitems)As System.Windows.Forms.Listviewitem.Listview.Subitem':参数匹配参数项无法从 DBNull 转换为 ListViewSubitems

4

1 回答 1

1

改成这个

.Items.Add(dr.Item(0).ToString())

这将忽略 null 并将空白字符串添加到项目

于 2012-10-22T13:24:24.917 回答