System.Data.DataRowView
Hello people. Ive got a problem with a listbox of mine. I have three lisboxes, one listbox1 is for product category, another lisbox2 is for the product itself in which it will appear after the user has chosen a product category AND another listbox3 which acts like a shopping cart in which the product that user has chosen will go to. When I click on product category there is no problem, the listbox2 will list all products, BUT when I select a product to go to my shopping cart(listbox3) this message will appear in listbox3 - System.Data.DataRowView
Here are my codes:
'I think the code below is where the problem can be found
Private Sub listCategory_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles listCategory.SelectedIndexChanged
Dim getCategoryDesc As MySqlCommand = New MySqlCommand("Select * from category where catDesc=@field2;", connection)
Dim reader1 As MySqlDataReader
Try
With getCategoryDesc
.Parameters.AddWithValue("@field2", listCategory.Text)
End With
reader1 = getCategoryDesc.ExecuteReader()
While (reader1.Read())
txtcatNo.Text = (reader1("catNo"))
End While
getCategoryDesc.Dispose()
reader1.Close()
Catch ex As Exception
End Try
Try
Dim category As String
category = listCategory.Text
Dim sqlcommand As String = "select product.prodNo, product.productDesc from product, category where category.catDesc='" & category & "' and product.catNo=category.catNo;"
Dim adapter As New MySqlDataAdapter(sqlcommand, connection)
Dim dataset As New DataSet
adapter.Fill(dataset, "product")
With listproduct
.ValueMember = "prodNo"
.DisplayMember = ("productDesc").ToString
.DataSource = dataset.Tables("product")
.SelectedValue = "prodNo"
.SelectedIndex = 0
End With
Catch ex As Exception
End Try
End Sub
' What the code below does is that when I click on an item that item will be transferred to my shopping cart(listbox3)
Private Sub listproduct_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles listproduct.SelectedIndexChanged
getprod()
Try
Dim i As Integer
For i = 0 To listproduct.SelectedItems.Count - 1
'Dim str As String =
listItemsBought.Items.Add(listproduct.SelectedItems.Item(i))
Next i
Catch ex As Exception
End Try
End Sub
so thats my problem you guys. Help would be really appreciated