📄 news.aspx.cs
字号:
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 new2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btuclick(object sender, EventArgs e)
{
string str = ((Button)sender).CommandArgument.ToString();
SqlConnection con = new SqlConnection("data source=localhost;uid=sa;pwd=;database=Ebusiness");
con.Open();
SqlCommand comm = new SqlCommand( );
comm.CommandText = "select title,content,Auth,[date],click from petnews1 where id=" + str;
comm.Connection = con;
SqlDataReader reader = comm.ExecuteReader();
reader.Read();
TextBox1.Text = reader.GetString(0);
TextBox6.Text = reader.GetString(1);
TextBox2.Text = reader.GetString(2);
TextBox5.Text = reader.GetDateTime(3).ToString();
TextBox3.Text = TextBox2.Text;
int i = reader.GetInt32(4);
i++;
TextBox4.Text = i.ToString(); //访问次数
//Session["content"] = null;
reader.Close();
//更新访问次数
comm.CommandText = "update petnews1 set click=" + i.ToString() + " where id=" + str;
comm.ExecuteNonQuery();
con.Close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -