Question Adding to listview from access database

Redmo

Member
Joined
Jul 1, 2006
Messages
7
Programming Experience
1-3
My problem is very simple, i have 4 columns at the moment, this code is supposed to add the column name, and then the details to a listview. Sounds easy, but what i am getting is that all the row details are being listed in column 1. Can anyone tell me why the rows are not been added to the right column?

VB.NET:
For i = 0 To ds.Tables("Contacts").Columns.Count - 1 'Counts the amount of columns in the database

            'Stores column name as string
            strColumnName = ds.Tables("Contacts").Columns.Item(i).ColumnName
            'Skip over column ID
            If strColumnName = "ID" Then

            Else
                'Add Column name to listview
                lv1.Columns.Add(strColumnName)

                'Loop until all row's have been added
                For j = 0 To ds.Tables("Contacts").Rows.Count - 1
                    'Add Row name to string
                    strRowName = ds.Tables("Contacts").Rows(j).Item(strColumnName).ToString

                    'Add string to listview
                    lv1.Items.Add(strRowName)
                Next

                lv1.Update()
            End If
            'add listviewitem (all of the columns from stored procedure from above) to the listview

        Next

Any help would be gratefully appreciated :)

Redmo
 
Back
Top