I have a form with a combobox and a listview. The combobox allows me to select a particular table in a database.
I have set up a stored procedure to select just the Firstname and Surname fields from the table.
I have also created a for/next loop to populate the listview with the first x number of rows of the table according to the limits of the loop.
If I set up the loop to populate with just one field then everything works fine. But if I then include the second field, I only get two or three of the field filled. So first column is complete with all names, but the second column contains some blank fields.
When I use a datagrid instead of a list view, the problem does not happen. Any idea why the listview does not populate fully? Code I'm using shown below..
Dim com As SqlCommand = SqlConnection1.CreateCommand
Dim da As SqlDataAdapter = New SqlDataAdapter
com.CommandType = CommandType.StoredProcedure
com.CommandText = "Spring04Confirmed"
da.SelectCommand = com
da.Fill(ds, "Spring04")
DataGrid1.DataSource = ds
DataGrid1.DataMember = "Spring04"
Dim i As Integer
For i = 1 To 15
ListView1.Items.Add(ds.Tables("Spring04").Rows(i).Item(1))
ListView1.Items(0).SubItems.Add(ds.Tables("Spring04").Rows(i).Item(0))
Next i
I have set up a stored procedure to select just the Firstname and Surname fields from the table.
I have also created a for/next loop to populate the listview with the first x number of rows of the table according to the limits of the loop.
If I set up the loop to populate with just one field then everything works fine. But if I then include the second field, I only get two or three of the field filled. So first column is complete with all names, but the second column contains some blank fields.
When I use a datagrid instead of a list view, the problem does not happen. Any idea why the listview does not populate fully? Code I'm using shown below..
Dim com As SqlCommand = SqlConnection1.CreateCommand
Dim da As SqlDataAdapter = New SqlDataAdapter
com.CommandType = CommandType.StoredProcedure
com.CommandText = "Spring04Confirmed"
da.SelectCommand = com
da.Fill(ds, "Spring04")
DataGrid1.DataSource = ds
DataGrid1.DataMember = "Spring04"
Dim i As Integer
For i = 1 To 15
ListView1.Items.Add(ds.Tables("Spring04").Rows(i).Item(1))
ListView1.Items(0).SubItems.Add(ds.Tables("Spring04").Rows(i).Item(0))
Next i