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 believe the code below is the problem

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

            With getCategoryDesc
                .Parameters.AddWithValue("@field2", listCategory.Text)
            End With

            reader1 = getCategoryDesc.ExecuteReader()
            If (reader1.Read()) Then
                txtcatNo.Text = (reader1("catNo"))
            End If


        Catch ex As Exception

        End 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"
                .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 the user clicks on an item it goes to the shoppingcart(listbox3)

    Private Sub listproduct_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles listproduct.SelectedIndexChanged

            Dim i As Integer
            For i = 0 To listproduct.SelectedItems.Count - 1
            Next i
        Catch ex As Exception

        End Try

    End Sub

so thats my problem you guys. Help would be really appreciated

6 Years
Discussion Span
Last Post by Oxiegen

What is the exact error message?
Put a messagebox in the Catch statement: MessageBox.Show(ex.ToString)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.