Click here to Skip to main content
15,899,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am trying to search in listview and i am using column16 to populate the record for the department name the objdatareader is trying to read column15 it's a deparment id for each row, now all i want is to identify column 15 to know the department name

the problem is when i populate the record it will display horizontally but i want is vertically...



here's my sample code

VB
  Dim objDataReader As OleDbDataReader
        objDataReader = objCommand.ExecuteReader
        If objDataReader.HasRows = 0 Then

            txtCostCenter.Text = ""
            txtDivision.Text = ""
        End If


        While objDataReader.Read






           

            For Each item2 As ListViewItem In lstLicense.Items
                With item2

                    item2.SubItems.Add(16).Text = (objDataReader("Division")).ToString

                End With
            Next
            '  Next
        End While

Dim v As Integer
 

       
        Dim aa As ListViewItem
        lstCostCenter.Items.Clear()
        Dim strSQL As String
 
        For Each item2 As ListViewItem In lstLicense.Items
 

            strSQL = "SELECT * FROM tblEndUserDetails WHERE CostCenter Like '" & item2.SubItems(15).Text & "%'"
 
            classLibrary = New ConLib
            classLibrary.openConnection(strConnection)
            lblconstat.Text = DatabaseStatus
            If Not classLibrary.isconnectionopen() Then
                Exit Sub
 
            End If
 
            classLibrary.initializeCommand(strSQL)
 
            populateDatAddCostCenterPopUpBox3()
 
        Next

End Sub
Posted
Updated 12-Sep-11 21:18pm
v6
Comments
Prerak Patel 12-Sep-11 4:58am    
What error you get?

Add like this.
lstLicense.Items.Insert(16, (objDataReader("Division")).ToString)
 
Share this answer
 
v2
i have 1 error 'Items is not a member of 'System.Windows.Forms.ListViewItem'.

actually i want is to display at column16 but the record is repeating horizontally
 
Share this answer
 
Comments
Toniyo Jackson 12-Sep-11 7:19am    
See the updated answer
i am trying to search in listview and i am using column16 to populate the record for the department name the objdatareader is trying to read column15 it's a deparment id for each row, now all i want is to identify column 15 to know the department name
VB
<pre lang="vb">
VB
Dim v As Integer


       
        Dim aa As ListViewItem
        lstCostCenter.Items.Clear()
        Dim strSQL As String

        For Each item2 As ListViewItem In lstLicense.Items


            strSQL = "SELECT * FROM tblEndUserDetails WHERE CostCenter Like '" & item2.SubItems(15).Text & "%'"

            classLibrary = New ConLib
            classLibrary.openConnection(strConnection)
            lblconstat.Text = DatabaseStatus
            If Not classLibrary.isconnectionopen() Then
                Exit Sub

            End If

            classLibrary.initializeCommand(strSQL)

            populateDatAddCostCenterPopUpBox3()

        Next

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900