title: Populating Listbox with data from SQL Server
body: <p>I don't know what is happening to my program, it took me (4) four minutes to load the result of my code.... can someone tell me why? Can someone tell me how to fix this loading problem?</p>
  
  <p>This is my code:</p>
  
  <pre><code>Imports System.Data.SqlClient
  Public Class Form1
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
          Dim str As String = "Data Source=######;Initial Catalog=###;Persist Security Info=True;User ID=#####;Password=#####"
          Dim con As New SqlConnection(str)
          Dim cmd As String = "Select ControlNo,EmpNo,CheckOutDate,CheckOutTime,TaxiNo,PlateNo,Model,Make from dbo.ChkInOut"
          Dim adpt As New SqlDataAdapter(com, con)
          Dim myDataSet As New DataSet()
          adpt.Fill(myDataSet, "dbo.ChkInOut")
          Dim myDataTable As DataTable = myDataSet.Tables(0)
          Dim tempRow As DataRow
          For Each tempRow In myDataTable.Rows
              'ListBox1.Items.Add((tempRow("ControlNo") &amp; " (" &amp; tempRow("EmpNo") &amp; ")" &amp; " (" &amp; tempRow("CheckOutDate") &amp; ")" &amp; " (" &amp; tempRow("CheckOutTime") &amp; ")" &amp; " (" &amp; tempRow("TaxiNo") &amp; ")" &amp; " (" &amp; tempRow("PlateNo") &amp; ")" &amp; " (" &amp; tempRow("Model") &amp; ")" &amp; " (" &amp; tempRow("Make") &amp; ")"))
              'ListBox1.Items.Add((tempRow("ControlNo") &amp; " (" &amp; tempRow("EmpNo") &amp; ")"))
              ListBox1.Items.Add(tempRow("ControlNo") &amp; "            " &amp; tempRow("EmpNo") &amp; "            " &amp; tempRow("CheckOutDate") &amp; "            " &amp; tempRow("CheckOutTime") &amp; "            " &amp; tempRow("TaxiNo") &amp; "            " &amp; tempRow("PlateNo") &amp; "            " &amp; tempRow("Model") &amp; "            " &amp; tempRow("Make") &amp; "            ")
          Next
      End Sub
  
  End Class
  </code></pre>