<%@ Page Language="C#"%> <%@ Import NameSpace = "System" %> <%@ Import NameSpace = "System.Data" %> <%@ Import NameSpace = "System.Data.SqlClient" %> <%@ Import NameSpace = "System.Web.Configuration" %> <% string pageTest = Request["page"]; int page; //目前所在頁數. bool result = IsNumeric(pageTest); //page為空值或非數字. if (!result) { page = 1; } else { page = Convert.ToInt32(pageTest); } int pageAll; //總頁數. int pageSize = 100; //每頁筆數. int totleCount = 0; //總筆數 //排序的依據,可依id或likeCount. string sequence = Request["seq"]; if (sequence == null) { sequence = "a001"; } string orderby = ""; if (sequence == "a002") { orderby = "likeCount"; } else { orderby = "id"; } SqlConnection Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["topicWriterConnectionString"].ConnectionString); SqlCommand Cmd = new SqlCommand(); SqlDataReader dr = null; //1.select總筆數. string SelTotleComm = "SELECT COUNT([id]) AS totleCount FROM [20160823_cheersPassLove] WHERE [isshow] = '1'"; Cmd = new SqlCommand(SelTotleComm, Conn); Conn.Open(); dr = Cmd.ExecuteReader(); while (dr.Read()) { totleCount = Convert.ToInt32(dr["totleCount"]); } pageAll = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(totleCount) / Convert.ToDouble(pageSize))); //close DB. if (dr != null) { Cmd.Cancel(); dr.Close(); } if (Conn.State == ConnectionState.Open) { Conn.Close(); } %> 你寫信我們捐書 - 千里傳愛7 - 環台單車公益活動 - 磐石保險經紀人

有您的愛,每一天都有新的可能,一起寫下您的愛心,關心困境中迷航的孩子。

你寫信我們捐書參與網友

<% //3.SELECT ALL DATA(前20[pageSize]筆) & ISSHOW = 1. string SelectListComm = "SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY " + orderby + " DESC,[insert_time]) AS RowNumber,* FROM [20160823_cheersPassLove] WHERE [isshow]='1') A WHERE RowNumber > " + pageSize + "*(" + Convert.ToString(page) + "-1) "; Cmd = new SqlCommand(SelectListComm, Conn); Conn.Open(); dr = Cmd.ExecuteReader(); while (dr.Read()) { string id = dr["id"].ToString(); string fbID = dr["fbID"].ToString(); string fbName = dr["fbName"].ToString(); string description = dr["description"].ToString(); %>
Thumbnail Image

<%=fbName %>

<%=description %>

<% } //close DB. if (dr != null) { Cmd.Cancel(); dr.Close(); } if (Conn.State == ConnectionState.Open) { Conn.Close(); Conn.Dispose(); } %>