资源简介
基于asp.net开发的简单个人博客系统,适合初学者下载学习。
代码片段和文件信息
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.SqlClient;
public partial class Article : System.Web.UI.Page
{
protected void Page_Load(object sender EventArgs e)
{
int id = Convert.ToInt32(Request.QueryString[“ID“].ToString());
if (id <= 0)
{
Response.Write(“请选择文章“);
Response.Redirect(“default.aspx“);
}
//读取数据库连接字符串
string settings = Convert.ToString(ConfigurationManager.ConnectionStrings[“SqlServices“]);
//创建数据库连接对象
SqlConnection myconn = new SqlConnection(settings);
myconn.Open();
string strsql = “select * from Articles Where ArticleID=“ + id;
SqlCommand mycmd = new SqlCommand(strsql myconn);
//SqlDataReader读取数据到记录集后,会自动关闭数据库的连接
SqlDataReader result = mycmd.ExecuteReader();
if (result.Read())
{
lbl_title.Text = result[“title“].ToString();
lbl_content.Text = “ “ + result[“A_Content“].ToString();
}
myconn.Close();
BindList();
}
void BindList()
{
int id = Convert.ToInt32(Request.QueryString[“ID“].ToString());
//读取数据库连接字符串
string settings = Convert.ToString(ConfigurationManager.ConnectionStrings[“SqlServices“]);
//创建数据库连接对象
SqlConnection myconn = new SqlConnection(settings);
myconn.Open();
string strsql = “select * from Comments Where ArticleID=“ + id;
SqlCommand mycmd = new SqlCommand(strsql myconn);
//SqlDataReader读取数据到记录集后,会自动关闭数据库的连接
SqlDataReader result = mycmd.ExecuteReader(CommandBehavior.CloseConnection);
gv_comment.DataSource = result;
gv_comment.DataBind();
}
protected void Foot1_Load(object sender EventArgs e)
{
}
protected void Button1_Click(object sender EventArgs e)
{
int id = Convert.ToInt32(Request.QueryString[“ID“].ToString());
string settings = Convert.ToString(ConfigurationManager.ConnectionStrings[“SqlServices“]);
SqlConnection myconn = new SqlConnection(settings);
myconn.Open();
string s = “insert into Comments ( Cmt_ContentCmt_UserNameCmt_TimeArticleID) values(‘“ + TextBox2.Text + “‘‘“ + TextBox1.Text + “‘‘“ + DateTime.Now + “‘“ + id + “)“;
SqlCommand cmd = new SqlCommand(s myconn);
cmd.ExecuteNonQuery();
myconn.Close();
Response.Redirect(“Default2.aspx“);
}
protected void Button2_Click(object sender EventArgs e)
{
this.TextBox1.Text = ““;
this.TextBox2.Text = ““;
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3089 2008-04-27 00:29 WebSite1\WebSite1\Article.aspx.cs
文件 1387 2008-04-13 22:31 WebSite1\WebSite1\board.aspx.cs
文件 565 2008-04-17 09:20 WebSite1\WebSite1\daohang.ascx
文件 415 2008-04-07 13:57 WebSite1\WebSite1\daohang.ascx.cs
文件 935 2008-04-09 14:02 WebSite1\WebSite1\Default.aspx.cs
文件 804 2008-04-25 14:24 WebSite1\WebSite1\Default2.aspx.cs
文件 412 2008-04-07 15:39 WebSite1\WebSite1\left.ascx.cs
文件 1141 2008-04-13 22:51 WebSite1\WebSite1\list.aspx.cs
文件 2194 2008-04-25 15:00 WebSite1\WebSite1\liuyan.aspx.cs
文件 1475 2008-04-13 22:52 WebSite1\WebSite1\Message.aspx.cs
文件 9745 2008-04-09 13:28 WebSite1\WebSite1\mouse.ascx
文件 413 2008-04-09 13:27 WebSite1\WebSite1\mouse.ascx.cs
文件 1405 2008-04-08 15:38 WebSite1\WebSite1\NewComment.ascx
文件 1198 2008-04-27 00:31 WebSite1\WebSite1\NewComment.ascx.cs
文件 1393 2008-04-08 15:17 WebSite1\WebSite1\NewList.ascx
文件 1197 2008-04-08 15:17 WebSite1\WebSite1\NewList.ascx.cs
文件 1246 2008-04-18 11:16 WebSite1\WebSite1\NewMsg.ascx
文件 1196 2008-04-08 14:41 WebSite1\WebSite1\NewMsg.ascx.cs
文件 2155 2008-04-26 21:30 WebSite1\WebSite1\photo.aspx
文件 1132 2008-04-25 16:13 WebSite1\WebSite1\photo.aspx.cs
文件 2665 2010-06-14 18:05 WebSite1\WebSite1\photolist.aspx
文件 1255 2008-04-18 14:44 WebSite1\WebSite1\photolist.aspx.cs
文件 474 2008-04-27 12:04 WebSite1\WebSite1\play.aspx.cs
文件 1350 2008-04-08 15:13 WebSite1\WebSite1\tags.ascx
文件 1184 2008-04-08 15:07 WebSite1\WebSite1\tags.ascx.cs
文件 415 2008-04-17 09:05 WebSite1\WebSite1\tiaochu.ascx.cs
文件 944 2008-04-11 15:23 WebSite1\WebSite1\videolist.aspx.cs
文件 8239 2010-06-14 16:42 WebSite1\WebSite1\tiaochu.ascx
文件 5857 2010-06-14 17:35 WebSite1\WebSite1\Default.aspx
文件 6032 2010-06-14 17:35 WebSite1\WebSite1\Default2.aspx
............此处省略62个文件信息
评论
共有 条评论