Ejemplo n.º 1
0
        public DataTable GetContato(int id)
        {
            DbConnection conexao = DAOUtils.GetConexao();
            DbCommand    comando = DAOUtils.GetComando(conexao);

            comando.CommandType = CommandType.Text;
            comando.CommandText = "SELECT * FROM CONTATOS WHERE ID = @id";
            comando.Parameters.Add(new SqlParameter("@id", id));

            DbDataReader reader    = DAOUtils.GetDataReader(comando);
            DataTable    dataTable = new DataTable();

            dataTable.Load(reader);
            return(dataTable);
        }
Ejemplo n.º 2
0
        public DataTable GetContatos()
        {
            DbConnection conexao = DAOUtils.GetConexao();
            DbCommand    comando = DAOUtils.GetComando(conexao);

            comando.CommandType = CommandType.Text;
            comando.CommandText = "SELECT * FROM CONTATOS";

            DbDataReader reader    = DAOUtils.GetDataReader(comando);
            DataTable    dataTable = new DataTable();

            dataTable.Load(reader);
            return(dataTable);

            //DbDataAdapter adapter = new SqlDataAdapter((SqlCommand)comando);
            //DataSet ds = new DataSet();
            //adapter.Fill(ds, "CONTATOS");
            //return ds;
        }