I am trying to retrieve data from SQL Server into my form. I am trying with the below code. When I run this I get the first item or row but I am unable load the rest of the items into my listview . Can someone help to solve my issue?
Sub GetInvoiceDetails()
Dim Inv As New petClass
Dim dt As DataTable = Inv.GetInvoiceDetailsbyNo(txtInvoiceNo.Text)
If dt.Rows.Count > 0 Then
For Each row In dt.Rows
srno += 1
Dim lstitem = Lstview.Items.Add(srno)
lstitem.SubItems.Add(dt.Rows(0).Item("ItemName").ToString)
lstitem.SubItems.Add(dt.Rows(0).Item("SellingPrice".ToString)).ToString()
Next
End If
'clearcontrols
End Sub
You’re always using the first row in the DataTable with
dt.Rows(0).Instead: