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