Ejemplo n.º 1
0
        protected DataTable obtienDatosTabla(string headCampos, string sql)
        {
            DataTable dt   = new DataTable();
            int       cont = 0;


            string[] words1 = headCampos.Split(',');
            //string[] words4 = aliasTablasCampoSel.Split('|');

            ArrayList headCol = new ArrayList();

            for (cont = 0; cont < words1.Length; cont++)
            {
                String campo = words1[cont];

                if (campo != "")
                {
                    headCol.Add(campo);
                    dt.Columns.Add(new DataColumn(campo, typeof(string)));
                }
            }

            ArrayList resp = ServiciosGen.getResultadoSQL(sql);

            if (resp != null)
            {
                ArrayList datCol = new ArrayList();
                for (int rowCtr = 0; (rowCtr < resp.Count); rowCtr++)
                {
                    datCol = (ArrayList)resp[rowCtr];

                    DataRow tRow = dt.NewRow();
                    for (int cellCtr = 0; cellCtr < datCol.Count; cellCtr++)
                    {
                        tRow[cellCtr] = datCol[cellCtr];
                    }
                    //  Add new row to table.
                    dt.Rows.Add(tRow);
                }
            }
            return(dt);
        }
Ejemplo n.º 2
0
        //-----------------------------------------------------------------------------------
        protected ArrayList obtienDatosTablaArray(string headCampos, string sql)
        {
            ArrayList dt   = new ArrayList();
            int       cont = 0;


            string[] words1 = headCampos.Split(',');
            //string[] words4 = aliasTablasCampoSel.Split('|');

            ArrayList headCol = new ArrayList();

            for (cont = 0; cont < words1.Length; cont++)
            {
                String campo = words1[cont];

                if (campo != "")
                {
                    headCol.Add(campo);
                }
            }
            dt.Add(headCol);
            ArrayList resp = ServiciosGen.getResultadoSQL(sql);

            if (resp != null)
            {
                ArrayList datCol = new ArrayList();
                for (int rowCtr = 0; (rowCtr < resp.Count); rowCtr++)
                {
                    datCol = new ArrayList();

                    ArrayList camposRec = (ArrayList)resp[rowCtr];
                    for (int cellCtr = 0; cellCtr < camposRec.Count; cellCtr++)
                    {
                        datCol.Add(camposRec[cellCtr]);
                    }

                    //  Add new row to table.
                    dt.Add(datCol);
                }
            }
            return(dt);
        }