Sunday, August 31, 2008

Populate ListView from SQL Server

Hello to all.

Today my sample is all above listview. Populate listview of data from database.

If you have ur connectionstring and recordset. Then set 1 listview and 1 commandbutton.

In your command button insert this code:

Dim Item as ListItem 'variable for your subitems

ListView1.ListItems.Clear 'Clear your Listview before loading a new data

While Not rs.eof

Set Item = ListView1.ListItems.Add(,,rs!One)
Item.Subitems(1) = rs!Two
rs.movenext

Wend

Hope this one will help you

2 comments:

Anonymous said...

While Not rs.eof
ListView1.ListItems.Add(,,rs!One)
ListView1.ListItems(ListView1.ListItems.count).IistSubitems.add (,, rs!Two)
rs.movenext

Wend

Anonymous said...

Populate listview with data