admin/login.aspx.cs
(完整代码) 2KBusing 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 login : 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)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
this.txt_admin.Text = "";
this.txt_password.Text = "";
}
protected void Button1_Click(object sender, EventArgs e)
{
//
if (this.txt_admin.Text == "" || this.txt_password.Text == "")
{
Response.Write("<script language=javascript>alert('请填写帐号和密码!');location='javascript:history.go(-1)'</script>");
}
else
{
string sql = "select * from adminuser where adminuser='"+this.txt_admin.Text+"' and password='"+this.txt_password.Text+"'";
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, "admin");//数据适配器向ds中装载表depart
DataTable dt = ds.Tables["admin"];//建立一个datatable对象dt,他的实例是da中的表dapart;
int count = dt.Rows.Count;
if (count == 0)
{
Response.Write("<script language=javascript>alert('帐号密码不正确!');</script>");
}
else
{
Session["admin"] ="admin";
Response.Redirect("index.aspx");
}
}
//
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
