日期:2008-09-26 浏览次数:20568 次
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Configuration;
using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.IO;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace makehtmlfile
{
/// <summary>
/// makefile2 的摘要说明。
/// </summary>
public class makefile2 : System.Web.UI.Page
{
public string strcon;
public OleDbConnection conn;
public string class1id;
public string class2id;
//***********************************
public string previd;
public string prevtitle;
public string nextid;
public string nexttitle;
//***********************************
public string newstitle;
public string newscontent;
public string newsdate;
public string newsip;
public string newsid;
//************************************
private void Page_Load(object sender, System.EventArgs e)
{
strcon = "provider=Microsoft.jet.OLEDB.4.0;data Source="+Server.MapPath(ConfigurationSettings.AppSettings["MDBpath2"])+";";//连接字符窜// 在此处放置用户代码以初始化页面
if(Request.Params["id"]!=null&&Request.Params["class1id"]!=null&&Request.Params["class2id"]!=null)
{
InitialPages();
}// 在此处放置用户代码以初始化页面
}
public void InitialPages()
{
strcon = "provider=Microsoft.jet.OLEDB.4.0;data Source="+Server.MapPath(ConfigurationSettings.AppSettings["MDBpath2"])+";";
if(Request.Params["id"]!=null)
{
newsid = Request.Params["id"].ToString();
}
if(Request.Params["class1id"]!=null)
{
class1id = Request.Params["class1id"].ToString();
}
if(Request.Params["class2id"]!=null)
{
class2id = Request.Params["class2id"].ToString();
}
ReadDataBase(newsid,class2id);
MakeHtmlFile(newsid,class1id,class2id);
}
/// <summary>
/// 读写同一分类中,上一篇,和下一篇文章
/// </summary>
/// <param name="inputid"> 该文章ID</param>
/// <param name="class2id">该文章所属分类ID</param>
public void ReadPrevAndNext(string inputid,string class2id)
{
int id = int.Parse(inputid);
string strPrevSQL = "select top 1 id,newstitle,newsdate from news where class2id='"+ class2id +"' and id<"+id+" order by id desc";
string strNextSQL = "select top 1 id,newstitle,newsdate from news where class2id='"+ class2id +"' and id>"+id+" order by id asc";
OleDbDataReader datar