如何使用datareader在vb.net的listview中显示记录

时间:2014-02-21 08:23:08

标签: vb.net

我希望使用Datareader使用vb.net和sqlserver在listview中显示记录 。任何人都可以发布链接或示例代码来帮助我吗?感谢。

1 个答案:

答案 0 :(得分:1)

试试这个:

Dim reader As SqlDataReader = Nothing
Try
    Dim myCommand As SqlCommand
    myCommand = New SqlCommand("SELECT  * FROM DoctorRegister ", Connection)
    reader = myCommand.ExecuteReader
    While reader.Read
        ListView1.Items.Add(reader.Item("FirstName")).Selected = True
    End While
Catch ex As Exception
    MsgBox(ex.Message)
Finally
    if reader IsNot Nothing Then
         reader.Close
    End IF
End Try