السلام عليكم ورحمة الله وبركاته
اريد كود لعرض بيانات جدول فى listview
الكود المستخدم لكنه يظهر كل ما فى الجدول وانا اريد اظهار بيانات محددة من الجدول وليس كل ما فى الجدول
Try
sql = "SELECT ID,firstname,lastname,gender,course FROM students"
con.Open()
da = New OleDb.OleDbDataAdapter(sql, con)
'fill the data to datatable
da.Fill(dt)
'declare a variable as DataRow which is represent a row of data
Dim newrow As DataRow
'loop from each row based on the number of rows stored in dt
For Each newrow In dt.Rows
'display the results in listview
ListView1.Items.Add(newrow.Item(0)) 'this is for ID
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(newrow.Item(1)) 'this is for Name
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(newrow.Item(2)) 'this is for Lastname
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(newrow.Item(3)) 'this is for gender
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(newrow.Item(4)) ' this is for course
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try