/// <summary>
        /// 数据源 run sql ,返回table .
        /// </summary>
        /// <param name="selectSql"></param>
        /// <returns></returns>
        public DataTable FromDBUrlRunSQLReturnTable(string selectSql)
        {
            // 得到数据源.
            DataTable dt = new DataTable();

            switch (this.FromDBUrl)
            {
            case DBUrlType.AppCenterDSN:
                dt = DBAccess.RunSQLReturnTable(selectSql);
                break;

            case DBUrlType.DBAccessOfMSMSSQL:
                dt = DBAccessOfMSMSSQL.RunSQLReturnTable(selectSql);
                break;

            case DBUrlType.DBAccessOfODBC:
                dt = DBAccessOfODBC.RunSQLReturnTable(selectSql);
                break;

            case DBUrlType.DBAccessOfOLE:
                dt = DBAccessOfOLE.RunSQLReturnTable(selectSql);
                break;

            case DBUrlType.DBAccessOfOracle:
                dt = DBAccessOfOracle.RunSQLReturnTable(selectSql);
                break;

            //case DBUrlType.DBAccessOfOracle1:
            //    dt=DBAccessOfOracle1.RunSQLReturnTable( selectSql );
            //    break;
            default:
                break;
            }
            return(dt);
        }
Exemplo n.º 2
0
        public static int Retrieve(Entity en, string sql, Paras paras)
        {
            DataTable dt;

            switch (en.EnMap.EnDBUrl.DBUrlType)
            {
            case DBUrlType.AppCenterDSN:
                dt = DBAccess.RunSQLReturnTable(sql, paras);
                break;

            case DBUrlType.DBAccessOfMSMSSQL:
                dt = DBAccessOfMSMSSQL.RunSQLReturnTable(sql);
                break;

            case DBUrlType.DBAccessOfOracle:
                dt = DBAccessOfOracle.RunSQLReturnTable(sql);
                break;

            default:
                throw new Exception("@没有设置DB类型。");
            }

            if (dt.Rows.Count == 0)
            {
                return(0);
            }
            Attrs attrs = en.EnMap.Attrs;

            EnDA.fullDate(dt, en, attrs);
            int i = dt.Rows.Count;

            dt.Dispose();
            return(i);
        }
Exemplo n.º 3
0
        public static int Retrieve(Entities ens, string sql)
        {
            try
            {
                DataTable dt = new DataTable();
                switch (ens.GetNewEntity.EnMap.EnDBUrl.DBUrlType)
                {
                case DBUrlType.AppCenterDSN:
                    dt = DBAccess.RunSQLReturnTable(sql);
                    break;

                case DBUrlType.DBAccessOfMSMSSQL:
                    dt = DBAccessOfMSMSSQL.RunSQLReturnTable(sql);
                    break;

                case DBUrlType.DBAccessOfOracle:
                    dt = DBAccessOfOracle.RunSQLReturnTable(sql);
                    break;

                case DBUrlType.DBAccessOfOLE:
                    dt = DBAccessOfOLE.RunSQLReturnTable(sql);
                    break;

                default:
                    throw new Exception("@没有设置DB类型。");
                }

                if (dt.Rows.Count == 0)
                {
                    return(0);
                }

                Map   enMap = ens.GetNewEntity.EnMap;
                Attrs attrs = enMap.Attrs;

                //Entity  en1 = ens.GetNewEntity;
                foreach (DataRow dr in dt.Rows)
                {
                    Entity en = ens.GetNewEntity;
                    //Entity  en = en1.CreateInstance();
                    foreach (Attr attr in attrs)
                    {
                        en.Row.SetValByKey(attr.Key, dr[attr.Key]);
                    }
                    ens.AddEntity(en);
                }
                int i = dt.Rows.Count;
                dt.Dispose();
                return(i);
                //return dt.Rows.Count;
            }
            catch (System.Exception ex)
            {
                // ens.GetNewEntity.CheckPhysicsTable();
                throw new Exception("@在[" + ens.GetNewEntity.EnDesc + "]查询时出现错误:" + ex.Message);
            }
        }
Exemplo n.º 4
0
        public static int Retrieve(Entities ens, string sql, Paras paras, string[] fullAttrs)
        {
            DataTable dt = null;

            switch (ens.GetNewEntity.EnMap.EnDBUrl.DBUrlType)
            {
            case DBUrlType.AppCenterDSN:
                dt = DBAccess.RunSQLReturnTable(sql, paras);
                break;

            case DBUrlType.DBAccessOfMSMSSQL:
                dt = DBAccessOfMSMSSQL.RunSQLReturnTable(sql);
                break;

            case DBUrlType.DBAccessOfOracle:
                dt = DBAccessOfOracle.RunSQLReturnTable(sql);
                break;

            case DBUrlType.DBAccessOfOLE:
                dt = DBAccessOfOLE.RunSQLReturnTable(sql);
                break;

            default:
                throw new Exception("@没有设置DB类型。");
            }

            if (dt.Rows.Count == 0)
            {
                return(0);
            }

            //设置查询.
            QueryObject.InitEntitiesByDataTable(ens, dt, fullAttrs);

            int i = dt.Rows.Count;

            dt.Dispose();
            return(i);
            //return dt.Rows.Count;
        }
Exemplo n.º 5
0
        public static int Retrieve(Entities ens, string sql, Paras paras, string[] fullAttrs)
        {
            DataTable dt = null;

            switch (ens.GetNewEntity.EnMap.EnDBUrl.DBUrlType)
            {
            case DBUrlType.AppCenterDSN:
                dt = DBAccess.RunSQLReturnTable(sql, paras);
                break;

            case DBUrlType.DBAccessOfMSMSSQL:
                dt = DBAccessOfMSMSSQL.RunSQLReturnTable(sql);
                break;

            case DBUrlType.DBAccessOfOracle:
                dt = DBAccessOfOracle.RunSQLReturnTable(sql);
                break;

            case DBUrlType.DBAccessOfOLE:
                dt = DBAccessOfOLE.RunSQLReturnTable(sql);
                break;

            default:
                throw new Exception("@没有设置DB类型。");
            }

            if (dt.Rows.Count == 0)
            {
                return(0);
            }

            if (fullAttrs == null)
            {
                Map   enMap = ens.GetNewEntity.EnMap;
                Attrs attrs = enMap.Attrs;
                try
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        Entity en = ens.GetNewEntity;
                        foreach (Attr attr in attrs)
                        {
                            en.Row.SetValByKey(attr.Key, dr[attr.Key]);
                        }
                        ens.AddEntity(en);
                    }
                }
                catch (Exception ex)
                {
                    #warning  应该出现的错误. 2011-12-03 add
                    string cols = "";
                    foreach (DataColumn dc in dt.Columns)
                    {
                        cols += " , " + dc.ColumnName;
                    }
                    throw new Exception("Columns=" + cols + "@Ens=" + ens.ToString() + "@SQL=" + sql + ". @异常信息:" + ex.Message);
                }
            }
            else
            {
                foreach (DataRow dr in dt.Rows)
                {
                    Entity en = ens.GetNewEntity;
                    foreach (string str in fullAttrs)
                    {
                        en.Row.SetValByKey(str, dr[str]);
                    }
                    ens.AddEntity(en);
                }
            }
            int i = dt.Rows.Count;
            dt.Dispose();
            return(i);
            //return dt.Rows.Count;
        }