admin/manage_st.aspx.cs
(开头部分) 2KB这里只显示每个文件的开头 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;
namespace 作业.admin
{
public partial class manage_st : 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();
}
}
//
public void bind()
{
string sql = "select * from student";//构造选出行业所有字段的SQL语句
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, "student");//数据适配器向ds中装载表depart
DataTable dt = ds.Tables["student"];//建立一个datatable对象dt,他的实例是da中的表dapart;
this.gv.DataSource = dt;
this.gv.DataBind();
}
protected void gv_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int id = Convert.ToInt32(this.gv.DataKeys[e.RowIndex].Value.ToString());
string sql = "delete from student where stu_id=" + id;
SqlCommand cmd = new SqlCommand();//创建了一个command对象cmd
Conn.Open();//打开CONN数据库连接对象
cmd.Connection = Conn;//设置cmd的连接对象是conn
cmd.CommandText = sql;//设置cmd对象的命令语句是sql
cmd.CommandType = CommandType.Text;//设置cmd命令的类型是Sql语句,而不是存储过程
cmd.ExecuteNonQuery();//执行命名,该函数返回一个整形数
bind();
}
//
//
public string bind_bj(int id)
{
string s;
string sql = "select * from bj where bj_id=" + id;
SqlCommand cmd = new SqlCommand(sql, Conn);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds, "fl");
DataTable dt = ds.Tables["fl"];
s = dt.Rows[0]["bj"].ToString();
后面还有 11 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
