none
Uma data table pode receber a uniao de vária tabelas? RRS feed

Respostas

  • Sim...

    private DataTable GetDataTable()
    {
      string sql = "SELECT t1.campo1,t1.campo2,t2.campo1,t2.campo2 FROM t1 inner join t2 on t1.id=t2.id";
      using (SqlConnection myConnection = new SqlConnection(connectionString))
      {
        using (SqlCommand myCommand = new SqlCommand(sql, myConnection))
        {
          myConnection.Open();
          using (SqlDataReader myReader = myCommand.ExecuteReader())
          {
            DataTable myTable = new DataTable();
            myTable.Load(myReader);
            myConnection.Close();
            return myTable;
          }
        }
      }
    }	

    att


    William John Adam Trindade
    Analyste-programmeur
    ----------------------------------------------------------

    Sogi informatique ltée


    domingo, 9 de dezembro de 2012 01:09
    Moderador