tijian_tieying/web/Web/Main/article.aspx.cs

49 lines
1.5 KiB
C#
Raw Normal View History

2025-02-20 12:14:39 +08:00
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Main_article : System.Web.UI.Page
{
protected string title = "";
protected string author = "";
protected string hits = "";
protected string updatetime = "";
protected string content="";
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string articleid = Request.QueryString["articleid"];
if (string.IsNullOrEmpty(articleid))
{
Response.Write("无效参数");
Response.End();
}
var dt = new DataTable();
try
{
var conn = new OleDbConnection(System.Configuration.ConfigurationManager.AppSettings["AccessConnectionString"]);
var adt = new OleDbDataAdapter("Select * from pe_article where articleid=" + articleid, conn);
adt.Fill(dt);
}
catch
{
Response.Write("<h4>无法获取网站数据</h4>");
Response.End();
}
title = dt.Rows[0]["title"].ToString();
author = dt.Rows[0]["author"].ToString();
hits = dt.Rows[0]["hits"].ToString();
updatetime = dt.Rows[0]["updatetime"].ToString().Split(' ')[0];
content = dt.Rows[0]["content"].ToString();
}
}
}