62,046
社区成员
发帖
与我相关
我的任务
分享
ALTER PROCEDURE [dbo].[gettracktype]
@pagecount int output,
@startIndex int,
@endIndex int
AS
select @pagecount=count(typeid) from tracktype
exec('SELECT * FROM (select *,ROW_NUMBER() OVER (ORDER BY typeid desc) AS rn
from tracktype)
AS c WHERE rn>='+@startIndex+' and rn<='+@endIndex+' order by rn ')
public static List<ShangWin_Model.Tracktype> gettracktype(int startIndex,int endIndex,out int pagecount)
{
SqlParameter[] paras = new SqlParameter[]{
new SqlParameter("@pagecount",SqlDbType.Int),
new SqlParameter("@startIndex",startIndex),
new SqlParameter("@endIndex",endIndex)
};
paras[0].Direction = ParameterDirection.Output;
List<ShangWin_Model.Tracktype> list = new List<ShangWin_Model.Tracktype>();
using (SqlDataReader dr = DBUtility_ShangWin.DbHelperSQL.ExecuteReader(CommandType.StoredProcedure, "gettracktype",paras))
{
while (dr.Read())
{
ShangWin_Model.Tracktype tt = new ShangWin_Model.Tracktype();
tt.Typeid = (dr["Typeid"] == DBNull.Value) ? 0 : Convert.ToInt32(dr["Typeid"]);
tt.Typename = dr["typename"].ToString();
tt.Addtime = (dr["addtime"] == DBNull.Value) ? Convert.ToDateTime("1900-01-01") : Convert.ToDateTime(dr["addtime"]);
tt.Remark = dr["remark"].ToString();
list.Add(tt);
}
pagecount = Convert.ToInt32(paras[0].Value);
}
return list;
}
using (SqlDataReader dr = DBUtility_ShangWin.DbHelperSQL.ExecuteReader(CommandType.StoredProcedure, "gettracktype",paras))
{
while (dr.Read())
{
ShangWin_Model.Tracktype tt = new ShangWin_Model.Tracktype();
tt.Typeid = (dr["Typeid"] == DBNull.Value) ? 0 : Convert.ToInt32(dr["Typeid"]);
tt.Typename = dr["typename"].ToString();
tt.Addtime = (dr["addtime"] == DBNull.Value) ? Convert.ToDateTime("1900-01-01") : Convert.ToDateTime(dr["addtime"]);
tt.Remark = dr["remark"].ToString();
list.Add(tt);
}
}
pagecount = Convert.ToInt32(paras[0].Value);