title: Populate ListView In VB.Net
body: <p>Code to show the data in two tables display in ListView (CODE WORKS PERFECTLY):</p>
  
  <pre><code>#Region "FillListView"
      Sub FillListview()
          LV.Items.Clear()
          myqry = "SELECT AccResult.StudNo,AccResult.CNumber,AccResult.FirstName,AccResult.LastName,AccResult.YrandSec,Exercises.Exer1,Exercises.Exer2,Exercises.Exer3,Exercises.Exer4,Exercises.Exer5 from AccResult INNER JOIN Exercises ON AccResult.StudNo = Exercises.StudNo ORDER BY AccResult.FirstName,AccResult.YrandSec Asc;"
  
          mycmd = New OleDbCommand(myqry, con)
          con.Open()
          mydr = mycmd.ExecuteReader
          While mydr.Read
              With LV
                  .Items.Add(mydr("StudNo"))
                  With .Items(.Items.Count - 1).SubItems
                      .Add(mydr("CNumber"))
                      .Add(mydr("FirstName"))
                      .Add(mydr("LastName"))
                      .Add(mydr("YrandSec"))
                      .Add(mydr("Exer1"))
                      .Add(mydr("Exer2"))
                      .Add(mydr("Exer3"))
                      .Add(mydr("Exer4"))
                      .Add(mydr("Exer5"))
                  End With
              End With
          End While
          con.Close()
      End Sub
  #End Region
  </code></pre>
  
  <p>Code for Populate ListView (ERROR):</p>
  
  <pre><code>Public Sub PopulateListView()
          Me.LV.Items.Clear()
          Dim OleDr As OleDb.OleDbDataReader
          OleDr = OleDa.SelectCommand.ExecuteReader() &lt;-----&lt; ERROR: The specified field '[StudNo]' could refer to more than one table listed in the FROM clause of your SQL statement.
  
          Do While OleDr.Read()
              Dim Item As New ListViewItem
              Item.Text = IIf(OleDr.IsDBNull(0), "", OleDr.Item(0))
  
              For shtCntr = 1 To OleDr.FieldCount() - 1
                  If Not OleDr.IsDBNull(shtCntr) Then
                      Item.SubItems.Add(OleDr.Item("CNumber"))
                      Item.SubItems.Add(OleDr.Item("FirstName"))
                      Item.SubItems.Add(OleDr.Item("LastName"))
                      Item.SubItems.Add(OleDr.Item("YrandSec"))
                      Item.SubItems.Add(OleDr.Item("Exer1"))
                      Item.SubItems.Add(OleDr.Item("Exer2"))
                      Item.SubItems.Add(OleDr.Item("Exer3"))
                      Item.SubItems.Add(OleDr.Item("Exer4"))
                      Item.SubItems.Add(OleDr.Item("Exer5"))
                  Else
                      Item.SubItems.Add("")
  
                  End If
              Next shtCntr
              Me.LV.Items.Add(Item)
          Loop
      End Sub
  </code></pre>
  
  <p>Code for Search:</p>
  
  <pre><code>Private Sub BSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BSearch.Click
          If txtSearch.Text = "" Then
                 MsgBox("Please enter keyword to search...", MsgBoxStyle.Information, "Keyword to search...")
              txtSearch.Focus()
              Exit Sub
          End If
          Call OpenConnection()
           With OleDa
              Call Initialized()
              .SelectCommand = New OleDb.OleDbCommand()
              .SelectCommand.CommandText = "SELECT * FROM [AccResult],[Exercises] WHERE StudNo Like '%%" &amp; txtSearch.Text &amp; "%%' or [YrandSec] Like '%%" &amp; txtSearch.Text &amp; "%%' or [LastName] Like '%%" &amp; txtSearch.Text &amp; "%%'" &amp; _
          "Or [FirstName] Like '%%" &amp; txtSearch.Text &amp; "%%' or [Exer1] Like '%%" &amp; txtSearch.Text &amp; "%%' or [Exer2] Like '%%" &amp; txtSearch.Text &amp; "%%' or [Exer3] Like '%%" &amp; txtSearch.Text &amp; "%%'" &amp; _
          "Or [Exer4] Like '%%" &amp; txtSearch.Text &amp; "%%' or [Exer5] Like '%%" &amp; txtSearch.Text &amp; "%%' ORDER By YrandSec, LastName ASC"
              .SelectCommand.Connection = OleCn
  
              Call PopulateListView()
  
               If Me.LV.Items.Count &gt;= 1 Then
                   MsgBox(Me.LV.Items.Count &amp; " Record(s) found for " &amp; "( " &amp; Me.txtSearch.Text &amp; " )", MsgBoxStyle.OkOnly, "Record(s) found...")
              Else
                   MsgBox("No record(s) found for " &amp; "( " &amp; Me.txtSearch.Text &amp; " )" &amp; " , please try again... ", MsgBoxStyle.Critical, "No record found...")
                  txtSearch.Focus()
                    txtSearch.SelectAll()
              End If
          End With
          Call CloseConnection()
  
      End Sub
  </code></pre>
  
  <p>How to populate listview after searching data in two data tables. It gives me error after searching. Thank You in advance.</p>