新闻发布系统是一款专为媒体机构、企业及个人设计的信息发布平台。它支持快速创建和分发各类新闻稿件,并提供数据分析功能以优化传播效果。
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
public partial class userShow : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.Label1.Text = System.DateTime.Now.ToString();
loadData();
}
protected void Button2_Click(object sender, EventArgs e)
{
OleDbConnection conn;
OleDbCommand cmd;
string olecmd, oleString,value;
value = this.TextBox1.Text;
Session.Add(key, value);
oleString = Provider=Microsoft.Jet.OLEDB.4.0;Data Source= + Server.MapPath(news.mdb);
olecmd = select * from userLoad where userName=;
olecmd += TextBox1.Text.Trim();
olecmd += and userPassword=;
olecmd += TextBox2.Text.Trim();
conn = new OleDbConnection(); //实例化对象
cmd = new OleDbCommand();
cmd.Connection = conn;
cmd.CommandText = olecmd;
if (this.TextBox1.Text.Trim() == || this.TextBox2.Text.Trim() == )
Response.Redirect(usersub.aspx);
try
{
conn.ConnectionString = oleString;
conn.Open();
OleDbDataReader dr = cmd.ExecuteReader();
if(dr.Read())
{
Session[username] = this.TextBox1.Text;
Response.Redirect(todayNews.aspx);
}
else
{
this.TextBox1.Focus();
this.TextBox1.Text = ;
this.TextBox2.Text = ;
}
} catch (Exception ex)
{
// 处理异常
}
finally
{
conn.Close();
dr.Close();
}
}
protected void Button3_Click(object sender, EventArgs e)
{
this.TextBox1.Focus();
this.TextBox1.Text = ;
this.TextBox2.Text = ;
}
DataSet GetDataSet()
{
OleDbConnection conn;
OleDbCommand cmd;
conn = new OleDbConnection();
string connectionString=Provider=Microsoft.Jet.OLEDB.4.0;Data Source= + Server.MapPath(news.mdb);
try
{
conn.ConnectionString = connectionString;
conn.Open();
cmd = new OleDbCommand();
cmd.CommandText = select * from newsData where newsclassid=0;
cmd.Connection = conn;
OleDbDataAdapter oleDA = new OleDbDataAdapter();
oleDA.SelectCommand = cmd;
DataSet ds = new DataSet();
oleDA.Fill(ds, newsData);
return ds;
} catch (Exception ex)
{
//处理异常
}
finally
{
conn.Close();
}
}
void loadData()
{
DataSet ds = GetDataSet();
GridView1.DataSource = ds;
GridView1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect(userLogin.aspx);
}
protected void GridView1_PageIndexChanging(object sender,GridViewPageEventArgs e)
{
GridView1.PageIndex=e.NewPageIndex;
loadData();
}
}