//定义参数
StreamWriter sw = null; StreamReader sr = null; string htmlfilename = "" ; string str1 = ""; int Count = 0; string path1 = HttpContext.Current.Server.MapPath("index.htm"); string path=HttpContext.Current.Server.MapPath("~/"); try { sr = new StreamReader(path1, Encoding.GetEncoding("GB2312")); str1 = sr.ReadToEnd(); } catch (Exception ex) { throw ex; } finally { sr.Close(); } // 数据库生成分页 int onepage = 2; string sSelect = "SELECT count(*) as pcount from newsTable"; DataClass dc = new DataClass(); using (OleDbDataReader Dr = dc.bindDataReader(sSelect)) { if (Dr.Read()) { Count = int.Parse(Dr["pcount"].ToString()); } dc.closeconn(); } int allpages = Count / onepage; for (int i = 1; i <= allpages; i++) { string str = str1; htmlfilename = "index_" + "" + i + "" + ".html"; int start = (i-1) * onepage; int nextpage = i + 1; int perpage = i - 1; if (i == 1) { start = 0; perpage =1; } if (perpage <= 0) { perpage = 1; } if (nextpage > allpages) { nextpage = i; } // 写文件 try { string vQuery = "SELECT TOP " + onepage + " * FROM newsTable WHERE (newsid NOT IN (SELECT TOP " + start + " newsid FROM newsTable ORDER BY newsid)) ORDER BY newsid"; if (i == 1) DataClass dc1 = new DataClass(); Response.Write("<script>alert('生成成功');history.back();</script>"); |
|