Populate Listview From Database

Creative2

Active member
Joined
Jan 7, 2003
Messages
31
Location
Toronto, Canada
Hi guys,

I am trying to fill a multicolumn listview by running a query, the problem I am having is that listview doesnt show first row items and subitems and if query just get one record then listview remains empty. I used following codes:

Do While Rdr.Read
Company = Rdr.GetValue(0)
Quote = Rdr.GetValue(1)
Platform = Rdr.GetValue(2)
QuoteDate = Rdr.GetDateTime(3)
PartNumber = Rdr.GetValue(4)
width = Rdr.GetValue(5)


lsvDetails.Items.Add(Company)
lsvDetails.Items(i).SubItems.Add(Quote)
lsvDetails.Items(i).SubItems.Add(Platform)
lsvDetails.Items(i).SubItems.Add(QuoteDate)
lsvDetails.Items(i).SubItems.Add(PartNumber)
lsvDetails.Items(i).SubItems.Add(width)
i += 1
Loop

Any suggestions to solve the problem??
 
I think the Rdr.Read function should come at the END of the loop.
Have a check beforehand to see if the number of records is more
than 0. Then run the loop, only put the Rdr.Read after the Loop
statement. This is because you are calling Rdr.Read once before
any code handles the first record, and its moving right to the
second record.

Code:
 Somehow check if any records exist, and skip the loop if there arent any

Do
   Do all your regular stuff here
Loop While Rdr.Read
 
Back
Top