Exemplo n.º 1
0
        /// <summary>
        /// 根据条件查询数据集
        /// </summary>
        public static DataTable SelectListData(string where = null, string selectFields = "*", string orderby = null, int top = 0, DbServers.DbServerName currDbName = DbServers.DbServerName.LatestDB)
        {
            if (!string.IsNullOrEmpty(where))
            {
                where = " Where " + where;
            }
            string selectSql = string.Format(@"Select {2} {1} From aspnet_Managers {0}", where, selectFields, top == 0 ? "" : "top " + top);

            if (!string.IsNullOrEmpty(orderby))
            {
                selectSql += " Order By " + orderby;
            }
            DataSet ds = DataAccessFactory.GetDataProvider(DbServers.GetCurrentDB(currDbName)).GetDataset(selectSql);

            ds.Tables[0].TableName  = "aspnet_Managers";
            ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns["UserId"] };
            return(ds.Tables[0]);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据条件查询首行首列
        /// </summary>
        public static object SelectScalar(string where = null, string selectFields = "*", string orderby = null, DbServers.DbServerName currDbName = DbServers.DbServerName.LatestDB)
        {
            if (!string.IsNullOrEmpty(where))
            {
                where = " Where " + where;
            }
            string selectSql = string.Format(@"Select {1} From aspnet_Managers {0}", where, selectFields);

            if (!string.IsNullOrEmpty(orderby))
            {
                selectSql += " Order By " + orderby;
            }
            return(DataAccessFactory.GetDataProvider(DbServers.GetCurrentDB(currDbName)).GetScalar(selectSql));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 根据主键删除
        /// </summary>
        public static void Del(int ID, DbServers.DbServerName currDbName = DbServers.DbServerName.LatestDB)
        {
            string deleteSql = string.Format(@"Delete From aspnet_Managers Where UserId={0}", ID);

            DataAccessFactory.GetDataProvider(DbServers.GetCurrentDB(currDbName)).Execute(deleteSql);
        }