info.aspx.cs
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.IO;
namespace 作业
{
public partial class info : System.Web.UI.Page
{
static string connstr = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];//定义静态链接数据库参数
SqlConnection Conn = new SqlConnection(connstr);//定义连接SQL数据库连接对象conn
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
bind();
this.txt_name.Text = Session["name"].ToString();
this.txt_xh.Text = Session["user"].ToString();
}
}
//
public void bind()
{
int id = int.Parse(Request.QueryString["id"].ToString());
string sql = "select * from zuoye where zuoye_id="+id;
SqlCommand cmd = new SqlCommand(sql, Conn);//创建一个command对象,装载的参数分别是SQL语句和一个连接对象Conn
SqlDataAdapter da = new SqlDataAdapter();//建立一个数据连接器
da.SelectCommand = cmd;//da的选择COMMAND对象是cmd
DataSet ds = new DataSet();//建立一个dataset
da.Fill(ds, "zuoye");//数据适配器向ds中装载表depart
DataTable dt = ds.Tables["zuoye"];//建立一个datatable对象dt,他的实例是da中的表zuoye;
this.lb_kc.Text = dt.Rows[0]["kc"].ToString();
this.lb_title.Text = dt.Rows[0]["title"].ToString();
this.lb_first.Text = dt.Rows[0]["first_date"].ToString();
this.lb_end.Text = dt.Rows[0]["end_date"].ToString();
}
//
protected void Button1_Click(object sender, EventArgs e)
{
int id = int.Parse(Request.QueryString["id"].ToString());
string sql = "select * from zuoye where zuoye_id="+id;
SqlCommand cmd = new SqlCommand(sql, Conn);//创建一个command对象,装载的参数分别是SQL语句和一个连接对象Conn
SqlDataAdapter da = new SqlDataAdapter();//建立一个数据连接器
da.SelectCommand = cmd;//da的选择COMMAND对象是cmd
DataSet ds = new DataSet();//建立一个dataset
da.Fill(ds, "zuoye");//数据适配器向ds中装载表depart
DataTable dt = ds.Tables["zuoye"];//建立一个datatable对象dt,他的实例是da中的表zuoye;
string filename = dt.Rows[0]["pic"].ToString();
Response.ContentType = "application/ms-download";
System.IO.FileInfo file = new System.IO.FileInfo(Server.MapPath(filename));//upload文件夹中存放了上传的资源文件,这里为资源文件的路径
Response.Clear();
Response.AddHeader("Content-Type", "application/octet-stream");
Response.Charset = "utf-8";
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(file.Name, System.Text.Encoding.UTF8));
Response.AddHeader("Content-Length", file.Length.ToString());
后面还有 51 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
