I am having a problem with a datareader.
Do While myData.Read
itmListItem = New ListViewItem()
strValue = IIf(myData.IsDBNull(0), "", myData.GetValue(0))
itmListItem.Text = strValue
For shtCntr = 1 To myData.FieldCount() - 1
If myData.IsDBNull(shtCntr) Then
itmListItem.SubItems.Add(" ")
Else
itmListItem.SubItems.Add(myData.GetString(shtCntr))
End If
Next shtCntr
view_data.DatabaseListView.Items.Add(itmListItem)
Loop
I have used message boxes for proofing. The code will make it through 6 loops and then throw the specified cast is not valid. It will pass the else, but I think the problem is in the if.
Does anyone have any clue?