SQL export to ListView using C#

I have a query that selects 3 columns from a SQL table, I need to export the resulting query into a listview. I don't need any help with the SQL setup, just how to format it into the listview. There is where I am stuck. Any help is appreciated. Thanks!

string sql = "select distinct pro,ds,date from dbo.Sge where date IN (select max(date) from dbo.Storage) order by project";
SqlConnection con = new SqlConnection("Data Source= ;Initial Catalog= ;Integrated Security= SSPI");
con.Open();
DataSet ds = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter(sql,con);
adapter.Fill(ds);
foreach (DataRow row in ds.Tables[0].Rows)
{
    for(int i=0; i< ds.Tables[0].Columns.Count; i++))
}

Edit: Sorry guys, i mentioned ListBox originally and i meant ListView. My ListView is detailed and had a column for each of my columns in my select, i just simply need the SQL export to go to the right column.

This is what I have come up with, but it doesn't add to each column, just to the first column

foreach (DataRow row in poplb6ds.Tables[0].Rows)
{
    listView1.Items.Add(row["Pro"].ToString());
    listView1.Items.Add(row["size"].ToString());
    listView1.Items.Add(row["Date"].ToString());
}

Answers


The following assumes that your ListView has columns in the order |Pro|Size|Date|

foreach (DataRow row in poplb6ds.Tables[0].Rows) {
    ListViewItem item = new ListViewItem(row["Pro"].ToString());
    item.SubItems.Add(row["size"].ToString());
    item.SubItems.Add(row["Date"].ToString());
    listView1.Items.Add(item);
}

Need Your Help

How to Check if other page field value is empty using jquery

javascript jquery confirm

I'm getting all contacts from Mysql db and then showing it on html row. Each row has onClick() method After click on each row it will show a details of contact to the right side of all contacts.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.