使用数据库中的列填充Listview?

时间:2014-02-05 11:43:13

标签: vb.net

我想用数据库中的0表填充listview,从combobox中选择表名,

 Dim ds As New DataSet()
 Dim ada As New SqlDataAdapter("Select COLUMN_NAME FROM  TABLE_NAME", con)
    MessageBox.Show(ComboBox1.SelectedText)
    ada.Fill(ds)
    Dim s As String = ""
    Dim lvi As ListViewItem = New ListViewItem()
    Dim myrow As DataRow
    For Each dt As DataTable In ds.Tables
        For Each myrow In dt.Rows
            Dim lv As New ListViewItem
            'lv.Text = myRow.Item(5)
            lv.SubItems.Add(myrow.Item(Convert.ToInt32(dt)))
            '   lv.SubItems.Add(myrow.Item(7))
            ListView1.Items.Add(lv)
        Next
    Next
    ' comboBox1.Items.Add(dt1);
    End Sub

0 个答案:

没有答案