title: Listview - populate second column with corresponding items from database
body: <p>Fist column of listview is populated from database (database column name KONTO - only values that starts with 2020-), second column of the listview should be populate from corresponding items to KONTO from same database column NAZIV into second column of the listview.</p>
  
  <p><img src="https://i.stack.imgur.com/De9Lz.jpg" alt="enter image description here">
  <em>Description is in column NAZIV in databsase</em></p>
  
  <p>I've been experimenting with this all day and didn't have any success. </p>
  
  <p>Here is the code I have so far :</p>
  
  <pre><code>        ListView1.View = System.Windows.Forms.View.Details
      ListView1.Columns.Add("COL1", 100, HorizontalAlignment.Left) 'KONTO
      ListView1.Columns.Add("COL2", 160, HorizontalAlignment.Left) 'NAZIV
  
  
  
      Dim FilePath As String = "W:\GLAVNI\KOR14\"
      Dim DBF_File As String = "MATIKGL"
      Dim ColName As String = "KONTO"
      'Dim naz As String
      Using con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &amp; FilePath &amp; _
      " ;Extended Properties=dBASE IV")
          con.Open()
          Using cmd As New OleDbCommand("SELECT * FROM MATIKGL ORDER BY KONTO, NAZIV", con)
              Using reader As OleDbDataReader = cmd.ExecuteReader()
                  If reader.HasRows Then
                      While (reader.Read())
                          Me.ListView1.Items.Add(reader("KONTO"))
  
                          'LOOP BELOW SELECTS ALL ITEMS THAT STARTS WITH 2020-
                          For i = 0 To ListView1.Items.Count - 1
                              If ListView1.Items(i).ToString.Contains("2020-") Then
  
                              Else
                                  ListView1.Items.Remove(ListView1.Items(i))
                              End If
                          Next
  
  
                      End While
  
                  Else
  
                  End If
              End Using
          End Using
          con.Close()
      End Using
  </code></pre>
  
  <p>Thanks.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>To be more clear, here is the screen from database.
  <img src="https://i.stack.imgur.com/uoiRE.jpg" alt="enter image description here"></p>
  
  <p>Only items starting with 2020- (1) should populate first column of listview, and second column should  be populated with "2020-" description from column NAZIV (2).</p>