title: how to use UNION in c#
body: <p>I am unable to successfully join two independent tables using ".Union" in C# and show all the columns in a grid. Can someone tell me how I can resolve this?</p>
  
  <pre><code>SqlCommand cmd;
  SqlCommand cmd1;
  SqlCommand cmd2;
  
  string cstr = ConfigurationManager.ConnectionStrings["college"]
                                    .ConnectionString;
  
  using (SqlConnection conn = new SqlConnection(cstr))
  {
      cmd1 = new SqlCommand("select * from student where studentFirstName LIKE '%'+@studentFirstName+'%'", conn);
      cmd1.Parameters.AddWithValue("@studentFirstName", input1);
      cmd2 = new SqlCommand("select * from employee where empFirstName LIKE '%'+@empFirstName+'%'", conn);
      cmd2.Parameters.AddWithValue("@empFirstName", input2);
      cmd = ((cmd1) .Union (cmd2));
  }
  
  SqlDataAdapter dAdapt = new SqlDataAdapter(cmd);
  DataSet dSet = new DataSet();
  dAdapt.Fill(dSet);
  </code></pre>