Cara Load Data Ke DataReader
Untuk VB.NET Codingnya Adalah :
Dim cmd As New Odbc.OdbcCommand("SELECT * FROM barang ORDER BY kode ASC", active_con)
Dim reader As Odbc.OdbcDataReader = cmd.ExecuteReader
With reader
If .HasRows = True Then
'Data ditemukan, maka bisa di aplikasikan tergantung kebutuhan
'Contoh di aplikasikan ke ListView
'Generate Column Header
For i As Integer = 0 To .FieldCount - 1
djie_ListView1.Columns.Add(.GetName(i).ToString)
Next
'Load Data
Do While .Read
djie_ListView1.Items.Add(.Item(0).ToString)
For i As Integer = 1 To .FieldCount - 1
djie_ListView1.Items(djie_ListView1.Items.Count - 1).SubItems.Add(.Item(i).ToString)
Next
Loop
djie_ListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize)
Else
MessageBox.Show("Data Tidak Ada Di Database !", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End With
Dim cmd As New Odbc.OdbcCommand("SELECT * FROM barang ORDER BY kode ASC", active_con)
Dim reader As Odbc.OdbcDataReader = cmd.ExecuteReader
With reader
If .HasRows = True Then
'Data ditemukan, maka bisa di aplikasikan tergantung kebutuhan
'Contoh di aplikasikan ke ListView
'Generate Column Header
For i As Integer = 0 To .FieldCount - 1
djie_ListView1.Columns.Add(.GetName(i).ToString)
Next
'Load Data
Do While .Read
djie_ListView1.Items.Add(.Item(0).ToString)
For i As Integer = 1 To .FieldCount - 1
djie_ListView1.Items(djie_ListView1.Items.Count - 1).SubItems.Add(.Item(i).ToString)
Next
Loop
djie_ListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize)
Else
MessageBox.Show("Data Tidak Ada Di Database !", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End With
Posting Komentar untuk "Cara Load Data Ke DataReader"