using System;
using System.Data.OleDb;
using System.Data.SqlClient;
using banco1.persistencia;
using System.Collections;

namespace banco1.domain.auxi
{
	/// <summary>
	/// Descripción breve de GestorDeListas.
	/// </summary>
	public class GestorDeListas
	{
		public static ArrayList getTabla(String tabla)
		{
			String SQL="Select * from [" + tabla + "]";
			return getVista(SQL);
		}

		public static ArrayList getVista(String SQL) {
			OleDbCommand cmd=Broker.getCommand(SQL);
			OleDbDataReader r=cmd.ExecuteReader();
			int columnas=r.FieldCount;
			ArrayList result=new ArrayList();
			object[] titulos=new object[columnas];
			for (int i=0; i<columnas; i++) 
			{
				titulos[i]=r.GetName(i);
			}
			result.Add(titulos);
			while (r.Read()) 
			{
				object[] fila=new object[columnas];
				for (int i=0; i<columnas; i++)
					fila[i]=r.GetValue(i);
				result.Add(fila);
			}
			cmd.Connection.Close();
			return result;
		}
	}
}
