예제 #1
0
        public List <Aluno> Pesquisar(int id, string banco, bool todosRegistros, string campoExtra, bool like, string campoPesquisa, string orderby)
        {
            string       sql = "";
            List <Aluno> ret = new List <Aluno>();

            try
            {
                Aluno obj = new Aluno();
                obj.ID_ALUNO = id;

                sql = LeituraObjetos_SQL.GerarSQLSelectDelete(obj, true, todosRegistros, campoExtra, like, campoPesquisa, orderby);

                DbDataReader rdr = null;
                switch (banco)
                {
                case "M":
                    rdr = ClasseConectar.mySql.ExecuteReader(sql);
                    break;

                case "L":
                    rdr = ClasseConectar.sqlLite.ExecuteReader(sql);
                    break;

                case "F":
                    rdr = ClasseConectar.fb.ExecuteReader(sql);
                    break;
                }

                while (rdr.Read())
                {
                    obj = (Aluno)LeituraObjetos_SQL.montagem(rdr, obj);
                    ret.Add(obj);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Erro : " + ex.Message + (ex.InnerException != null ? ex.InnerException.ToString() : String.Empty));
            }
            return(ret);
        }
예제 #2
0
        public List <Aluno> PesquisarSQLIVRE(string banco, string sql)
        {
            List <Aluno> ret = new List <Aluno>();

            try
            {
                Aluno obj = new Aluno();

                DbDataReader rdr = null;
                switch (banco)
                {
                case "M":
                    rdr = ClasseConectar.mySql.ExecuteReader(sql);
                    break;

                case "L":
                    rdr = ClasseConectar.sqlLite.ExecuteReader(sql);
                    break;

                case "F":
                    rdr = ClasseConectar.fb.ExecuteReader(sql);
                    break;
                }

                while (rdr.Read())
                {
                    obj = (Aluno)LeituraObjetos_SQL.montagem(rdr, obj);
                    ret.Add(obj);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Erro : " + ex.Message + (ex.InnerException != null ? ex.InnerException.ToString() : String.Empty));
            }
            return(ret);
        }