ListView da Access Veritabanındaki Verileri Göstermek
Bu makalemizde access veritabanındaki personel tablosundaki bilgileri Listview nesnesinde göstereceğiz. Aşağıdaki şekilleri inceleyin.
Imports System.Data.OleDb
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListView1.View = View.Details
ListView1.GridLines = True
ListView1.Columns.Add("id", 100, HorizontalAlignment.Center)
ListView1.Columns.Add("Ad", 100, HorizontalAlignment.Center)
ListView1.Columns.Add("Soyad", 100, HorizontalAlignment.Center)
ListView1.Columns.Add("Ogrenim", 100, HorizontalAlignment.Center)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListView1.Items.Clear()
Dim baglan As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=veri.mdb;")
Dim adp As New OleDb.OleDbDataAdapter()
adp.SelectCommand = New OleDb.OleDbCommand("Select * From personel", baglan)
baglan.Open()
Dim ds1 As New DataSet()
adp.Fill(ds1)
baglan.Close()
Dim item As New ListViewItem
For Each row As DataRow In ds1.Tables(0).Rows
item = ListView1.Items.Add(row.Item("id"))
item.SubItems.Add(row.Item("Ad"))
item.SubItems.Add(row.Item("Soyad"))
item.SubItems.Add(row.Item("Ogrenim"))
Next
End Sub
End Class
Bir sonraki makalede görüşmek üzere. Bahadır ŞAHİN