예제 #1
0
파일: DBH.cs 프로젝트: chloerager/light
        /// <summary>
        /// 统计待查询的记录总数
        /// </summary>
        /// <param name="tableName">数据源表名</param>
        /// <param name="where">where子句</param>
        /// <returns>记录条数</returns>
        public static int Count(string connectionString, string tableName, string where)
        {
            SqlParameter whereSQL = new SqlParameter("@where_sql", SqlDbType.NVarChar, 1500);

            whereSQL.Value = where;
            return(DBH.GetInt32(connectionString, CommandType.StoredProcedure, SP_PAGING, new SqlParameter[] {
                new SqlParameter("@tblname", tableName),
                new SqlParameter("@fields", ""),
                new SqlParameter("@sortfield", ""),
                new SqlParameter("@start", "0"),
                new SqlParameter("@end", "0"),
                new SqlParameter("@is_count", "1"),
                new SqlParameter("@ordertype", ""),
                whereSQL
            }));
        }
예제 #2
0
파일: DBH.cs 프로젝트: chloerager/light
        /// <summary>
        ///  获取分页数据集
        /// </summary>
        /// <param name="tableName">数据源表明</param>
        /// <param name="fields">获取的字段列表</param>
        /// <param name="sortField">排序字段</param>
        /// <param name="start">开始的记录数</param>
        /// <param name="end">结束的记录数</param>
        /// <param name="orderType">默认为0升序排列(ASC),1为降序排列(DESC)</param>
        /// <param name="where">where子句</param>
        /// <returns>返回排序结果</returns>
        public static IDataReader Paging(string connectionString, string tableName, string fields, string sortField, int start, int end, string orderType, string where)
        {
            SqlParameter whereSQL = new SqlParameter("@where_sql", SqlDbType.NVarChar, 2000);

            whereSQL.Value = where;
            return(DBH.ExecuteReader(connectionString, CommandType.StoredProcedure, SP_PAGING, new SqlParameter[] {
                new SqlParameter("@tblname", tableName),
                new SqlParameter("@fields", fields),
                new SqlParameter("@sortfield", sortField),
                new SqlParameter("@start", start),
                new SqlParameter("@end", end),
                new SqlParameter("@is_count", "0"),
                new SqlParameter("@ordertype", orderType),
                whereSQL
            }));
        }
예제 #3
0
파일: DBH.cs 프로젝트: chloerager/light
 /// <summary>
 ///  检查是否
 /// </summary>
 /// <param name="connectionString"></param>
 /// <param name="table"></param>
 /// <param name="field"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public static bool Exists(string connectionString, string table, string field, string value)
 {
     return(DBH.GetBoolean(connectionString, CommandType.Text, "SELECT COUNT(*) AS VALUE FROM " + table + " WHERE " + field + "=@value",
                           new SqlParameter("@value", value)));
 }
예제 #4
0
파일: DBH.cs 프로젝트: chloerager/light
 public static int Inc(string connectionString, string tableName, string fieldName, string priKey, string priValue)
 {
     return(DBH.ExecuteText(connectionString, "UPDATE " + tableName + " SET " + fieldName + "=" + fieldName + "+1 WHERE " + priKey + "='" + priValue + "'"));
 }