日期:2014-05-18 浏览次数:20420 次
string strpagenum = context.Request["pagenum"]; int ipagenum = Convert.ToInt32(strpagenum); using (SqlConnection conn = new SqlConnection(@"Data Source=123-PC\SQL2005;Initial Catalog=ZJJ;User ID=sa")) { conn.Open(); using(SqlCommand cmd=conn.CreateCommand()) { cmd.CommandText = "select * from(select id,title,price,imgurl,Row_Number() over(order by id) as rownum from tb_products)a where a.rownum>=" + ((ipagenum - 1) * 15) + 1 + "and rownum<=" + ipagenum * 15 + " "; DataSet ds = new DataSet(); SqlDataAdapter adapter = new SqlDataAdapter(cmd); adapter.Fill(ds); DataTable table = ds.Tables[0]; int count = table.Rows.Count;
select * from(select id,title,price,imgurl,Row_Number() over(order by id) as rownum from tb_products)a where a.rownum>= ((1 - 1) * 15) + 1 and rownum<=1 * 15 select * from(select id,title,price,imgurl,Row_Number() over(order by id) as rownum from tb_products)a where a.rownum>= ((2 - 1) * 15) + 1 and rownum<=2 * 15
"select * from(select id,title,price,imgurl,Row_Number() over(order by id) as rownum from tb_products)a where a.rownum>=" + (((ipagenum - 1) * 15) + 1).ToString() + " and rownum<=" + (ipagenum * 15).ToString() + " ";