L
Loogie
I am trying to add values to a listview but it keeps throwing an error
saying
System.InvalidCastException was unhandled
Message="InvalidCastException"
I am using VB.Net 2005 compact framework
Here is my code and I put a message beside where the error is thrown
Dim cmd As New System.Data.SqlServerCe.SqlCeCommand("Select p_item,
p_code, p_name from product", ssceconn)
Dim myReader As SqlCeDataReader = cmd.ExecuteReader()
If Not clsGlobals.Form4 Is Nothing Then
clsGlobals.Form4.lsvProds.Items.Clear()
Dim lvi As ListViewItem
Do While myReader.Read()
lvi = clsGlobals.Form4.lsvProds.Items.Add(myReader("p_item"))
- ERROR THROWN HERE
'note - I tried lvi =
clsGlobals.Form4.lsvProds.Items.Add(myReader("p_item").ToString) but it
creates an error value of type string can not be converted to
system.windows.forms.listviewitem
lvi.SubItems.Add(myReader("p_code").ToString)
lvi.SubItems.Add(myReader("p_name").ToString)
Loop
End If
Any help appreciated
saying
System.InvalidCastException was unhandled
Message="InvalidCastException"
I am using VB.Net 2005 compact framework
Here is my code and I put a message beside where the error is thrown
Dim cmd As New System.Data.SqlServerCe.SqlCeCommand("Select p_item,
p_code, p_name from product", ssceconn)
Dim myReader As SqlCeDataReader = cmd.ExecuteReader()
If Not clsGlobals.Form4 Is Nothing Then
clsGlobals.Form4.lsvProds.Items.Clear()
Dim lvi As ListViewItem
Do While myReader.Read()
lvi = clsGlobals.Form4.lsvProds.Items.Add(myReader("p_item"))
- ERROR THROWN HERE
'note - I tried lvi =
clsGlobals.Form4.lsvProds.Items.Add(myReader("p_item").ToString) but it
creates an error value of type string can not be converted to
system.windows.forms.listviewitem
lvi.SubItems.Add(myReader("p_code").ToString)
lvi.SubItems.Add(myReader("p_name").ToString)
Loop
End If
Any help appreciated