Dili1234 -2 Junior Poster

hi i'm doing a vb application to inventory mangement system

    Private Sub AppendItem(ByVal Major As String)
        myConnection = New SqlConnection(connectionstring)
        myConnection.Open()
        Dim TempData As New DataTable
        myCommand1 = New SqlCommand("Select Departement,Suject_Name From Major Where MajorName='" & ComboBox1.SelectedItem & "'", myConnection)
        myCommand1.ExecuteNonQuery()
        'sqlcmd = New SqlCommand("SELECT P_Id,P_Selling_Price FROM Product_Details WHERE P_Id='" & pid & "' ", myConnection)
        Dim dr As SqlDataReader = myCommand1.ExecuteReader
        ListView1.Items.Clear()
        dr.Read()


        Dim i As Integer
        ''''''''''''''''''''''''
        For i = 0 To TempData.Rows.Count-1
            Dim newItem As New ListViewItem(Major)
            'newItem.SubItems.Add(TempData.Rows(i)("Departement"))
            ' newItem.SubItems.Add(TempData.Rows(i)("Suject_Name"))
            newItem.SubItems.Add(dr("Departement"))
            newItem.SubItems.Add(dr("Suject_Name"))
            'ListView1.Items.Add(newItem)

        Next

        ''''''''''''''''''''''''''''''''''''''''''''''''''''''


        myConnection.Close()
    End Sub

can any body help me how to write coding when an item selected from combobox, i want to add the relvant data of that from database to the list view when combox selected

this is the coding i used in but it didn't work

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.