title: ds.tables(0) = 'ds.tables(0)' threw an exception of type 'System.NullReferenceException' vb.net
body: <p>Im trying to pull data from 2 different tables in one button click event. I've checked over everything and doesn't seem to be any typo's or anything but keep getting this error.</p>
  
  <p>Below is my code for the button click event</p>
  
  <pre><code>Protected Sub btnFindRepair_Click(sender As Object, e As EventArgs) Handles btnFindRepair.Click
  
      Dim connection As New SqlConnection("Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\ITrepair.mdf;Integrated Security=True")
  
      Dim command As New SqlCommand("SELECT * from Repair; SELECT * FROM Customer WHERE Tracking_Number = @Tracking_Number", connection)
  
      command.Parameters.Add("@Tracking_Number", SqlDbType.Int).Value = txtTrackingNumber.Text
  
      Dim adapter As New SqlDataAdapter(command)
      Dim ds As System.Data.DataSet
      Dim table As New DataTable()
  
      adapter.Fill(table)
  
  
      'Repair Details
      DDLBookedInBy.SelectedItem.Text = ""
      DDLDeviceType.SelectedItem.Text = ""
      txtBookedInDate.Text = ""
      txtDeviceName.Text = ""
      DDLAccessories.SelectedItem.Text = ""
      txtDevicePassword.Text = ""
      DDLRepairType.Text = ""
      txtTechnical.Text = ""
      txtCompletedNotes.Text = ""
      DDLRepairStatus.Text = ""
  
      'Customer Details
  
      txtFname.Text = ""
      txtLname.Text = ""
      txtContactNum.Text = ""
      txtAltContactNum.Text = ""
      txtAddress.Text = ""
  
  
      If table.Rows.Count() &gt; 0 Then
  
          ' return only 1 row
          DDLBookedInBy.SelectedItem.Text = ds.tables(0).Rows(0)(2).ToString()
          DDLDeviceType.SelectedItem.Text = ds.tables(0).Rows(0)(3).ToString()
          txtBookedInDate.Text = ds.tables(0).Rows(0)(4).ToString()
          txtDeviceName.Text = ds.tables(0).Rows(0)(5).ToString()
          DDLAccessories.SelectedItem.Text = ds.tables(0).Rows(0)(6).ToString()
          txtDevicePassword.Text = ds.tables(0).Rows(0)(7).ToString()
          DDLRepairType.Text = ds.tables(0).Rows(0)(8).ToString()
          txtTechnical.Text = ds.tables(0).Rows(0)(9).ToString()
          txtCompletedNotes.Text = ds.tables(0).Rows(0)(10).ToString()
  
          txtFname.Text = ds.tables(1).Rows(1)(4).ToString()
          txtLname.Text = table.Rows(1)(5).ToString()
          txtContactNum.Text = table.Rows(1)(6).ToString()
          txtAltContactNum.Text = table.Rows(1)(7).ToString()
          txtAddress.Text = table.Rows(1)(8).ToString()
  
      Else
          MsgBox("NO DATA found")
      End If
  
  
  
  
  End Sub
  </code></pre>