I tried this code to load the data in ListView1
The problem : it show me this Error: insexout of range exception was unhandeled at this line:
"adi.SubItems.Add(dr.Item("b").ToString)"
I treid this code without that line like this and it succeed with me
The problem : it show me this Error: insexout of range exception was unhandeled at this line:
"adi.SubItems.Add(dr.Item("b").ToString)"
VB.NET:
ListView1.Items.Clear()
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;"
& "Data Source =" & Application.StartupPath & "\Data.mdb ")
Dim cmd As New OleDbCommand("SELECT a, sum(b) FROM Table3 Group by a ", conn)
conn.Open()
Dim dr As OleDbDataReader = cmd.ExecuteReader
Do While dr.Read()
Dim adi As New ListViewItem(dr.Item("a").ToString)
adi.SubItems.Add(dr.Item("b").ToString) ' [COLOR="SeaGreen"]the error is here[/COLOR]
ListView1.Items.Add(adi)
Loop
conn.Close()
ListView1.View = View.Details[/HIGHLIGHT]
VB.NET:
Dim adi As New ListViewItem(dr.Item("a").ToString)
ListView1.Items.Add(adi)