I’m not sure why this isn’t working. I’m trying to display 2 columns from my database side by side in a listview box on my form. When I use this it doesn’t display any of the data correctly.
("SELECT Person FROM tblPeople" + " SELECT Occur FROM tblpeople" , conn);
try
{
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
listView1.Items.Add(reader["People"].ToString());
listView1.Items.Add(reader["Occur"].ToString());
}
So i’m looking for my data to display like this:
John 3
James 4
Frank 1
As the names are coming from column People and the numbers are coming from column Occur.
To get the desired effect, you should set the view style to
Detailsand add the second column value as sub-item.Basically, you should do something like this: