示例#1
0
        private void retrieveFromDB()
        {
            AbsDatabase db = ServiceManager.GetDatabase();
            int         keyFromDB;

            string sqlUpdate = "UPDATE KeyTable SET keyValue = keyValue + "
                               + poolSize + " WHERE keyName = '"
                               + keyName + "'";

            string sqlGetNewKey = "SELECT keyValue FROM KeyTable WHERE KeyName = '"
                                  + keyName + "'";

            try
            {
                db.ExecuteNonQuery(sqlUpdate);

                keyFromDB = (Int32)db.ExecuteScalar(sqlGetNewKey);
            }
            catch (Exception)
            {
                throw;
            }

            this.keyMax  = keyFromDB;
            this.keyMin  = keyFromDB - poolSize + 1;
            this.nextKey = this.keyMin;
        }
示例#2
0
        /// <summary>
        /// 获得只包含表结构的DataSet,用于除_Default以外的数据源
        /// </summary>
        /// <param name="p_db">AbsDatabase对象</param>
        /// <param name="p_tableName">表名</param>
        /// <returns>DataSet</returns>
        public static DataSet GetEmptyEntity(AbsDatabase p_db, string p_tableName)
        {
            string key = p_db.GetRealOne().ConnectionString + p_tableName;

            if (!hashEntities.ContainsKey(key))
            {
                try
                {
                    string  tableName = p_tableName.Trim();
                    string  strSql    = string.Format("select * from {0} where 0=1", tableName);
                    DataSet ds        = p_db.GetEntity(strSql, tableName);
                    hashEntities.Add(key, ds);
                    return(ds.Clone());
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            else
            {
                return((hashEntities[key] as DataSet).Clone());
            }
        }
示例#3
0
 /// <summary>
 /// 取得空实体,带详细模式
 /// </summary>
 /// <param name="p_db">AbsDatabase</param>
 /// <param name="p_tableName">表名</param>
 /// <returns></returns>
 public static DataSet GetEmptyEntityWithSchema(AbsDatabase p_db, string p_tableName)
 {
     return(GetEmptyEntityWithSchema("select * from " + p_tableName,
                                     p_tableName, p_db));
 }
示例#4
0
        internal static DataSet GetEmptyEntityWithSchema(string selStr, string tableName, AbsDatabase db)
        {
            string key = selStr + db.GetRealOne().ConnectionString;

            if (hashEntitiesWithSchema.ContainsKey(key))
            {
                return((hashEntitiesWithSchema[key] as DataSet).Clone());
            }
            else
            {
                DataSet        ds      = new DataSet();
                IDbDataAdapter adapter = db.GetDataAdapter(selStr);
                adapter.FillSchema(ds, SchemaType.Source);
                ds.Tables[0].TableName      = tableName;
                hashEntitiesWithSchema[key] = ds;
                return(ds.Clone());
            }
        }