Beispiel #1
0
        public static DataRow getRow(IDbPersist conn, string tabela, string pk, string id)
        {
            string sql = " select * from " + tabela + " where " + pk + "  = " + id;


            DataTable ds = new DataTable();

            ds = ConnAccess.fetchData(conn, sql);

            ds.TableName = tabela;

            if (ds.Rows.Count > 0)
            {
                return(ds.Rows[0]);
            }

            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// Cria um DataRow de dados vazio
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="tabela"></param>
        /// <returns></returns>
        public static DataRow getNewRow(IDbPersist conn, string tabela)
        {
            string sql = " select * from " + tabela + " where 1 = 0 ";

            DataTable ds = new DataTable();

            try
            {
                ds = ConnAccess.fetchData(conn, sql);
                DataRow drr = ds.NewRow();

                drr.Table.TableName = tabela;
                return(drr);
            }
            catch (Exception exp)
            {
                throw exp;
            }

            return(null);
        }
Beispiel #3
0
        /// <summary>
        /// Obtém uma linha DataRow.
        /// </summary>
        /// <param name="conn">Conexão Usada</param>
        /// <param name="tabela"></param>
        /// <param name="comp"></param>
        /// <returns></returns>
        public static DataRow getRow(IDbPersist conn, string tabela, string comp)
        {
            string sql = " select * from " + tabela + " where  1 = 1 " + comp;

            try
            {
                DataTable ds = new DataTable();
                ds = ConnAccess.fetchData(conn, sql);

                ds.TableName = tabela;

                if (ds.Rows.Count > 0)
                {
                    return(ds.Rows[0]);
                }
            }
            catch (Exception exp)
            {
                throw new Exception(sql + " - " + exp.Message);
            }
            return(null);
        }