title: Importing a DataRow to a new DataTable results in error. VB.NET
body: <p>I've been put on an older project vb.net project. I am trying to query a datatable and import the resulting DataRow into a newly created DataTable.  </p>
  
  <p>Code:</p>
  
  <pre><code>    Private Sub FilterSelectedByString(ByVal str As String, ByVal mID As Integer)
          Try
              dsTargetEmployees = MemberShipManager.GetMessageTargets(_page.Client, mID)
              dtTargets = dsTargets.Tables("MessageTargets")
              Dim dt As DataTable = Nothing
              For Each dr As DataRow In dtTargets.Select(str)
                  dt.ImportRow(dr)
              Next
              lstSelected.Items.Clear()
              lstSelected.DataSource = dt
              lstSelected.DataTextField = "EmployeeName"
              lstSelected.DataValueField = "EmployeeID"
              lstSelected.DataBind()
          Catch ex As Exception
             //error code
          End Try
      End Sub
  </code></pre>
  
  <p>This results in an "object not set to an instance of an object" error in the for loop. I've tried creating the data columns in the table manually, but that also results in the same error.</p>