日期:2014-05-17 浏览次数:20486 次
ALTER procedure [dbo].[fyinnovationbyzitem](@pagesize int,@currpage int,@totalrecords int output,@zid int,@zitem char)
as
begin
declare @total int;
set @total = (select COUNT(*) from Innovation where Cast(@zitem as nvarchar(50)) = @zid);
set @totalrecords = @total;
select top(@pagesize) * from Innovation where Id not in (select top((@currpage - 1)*@pagesize) Id from Innovation where Cast(@zitem as nvarchar(50)) = @zid) and Cast(@zitem as nvarchar(50)) = @zid;
end
public IList<Innovation> fyinnovationbyzitem(int pagesize, int currpage, out int totalrecords,int zid,string zitem)
{
IList<Innovation> lt = new List<Innovation>();
string cs = Dbunit.ConnectionString;
SqlConnection conn = new SqlConnection(cs);
SqlParameter[] sp = new SqlParameter[5];
sp[0] = new SqlParameter("@pagesize", pagesize);
sp[1] = new SqlParameter("@currpage", currpage);
sp[2] = new SqlParameter("@totalrecords", SqlDbType.Int, 4);
sp[2].Direction = ParameterDirection.Output;
sp[3] = new SqlParameter("@zid", zid);
sp[4] = new SqlParameter("@zitem", zitem);
using (SqlDataReader sdr = Dbunit.ExecuteReader("fyinnovationbyzitem", CommandType.StoredProcedure, sp))
{
if (sdr != null)
{
Innovation inn = null;
while (sdr.Read())
{
inn = new Innovation();