studentlogin.aspx.cs

来自「C#+ACCESS在线选课系统的设计与实现」· CS 代码 · 共 49 行

CS
49
字号
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.OleDb;

public partial class StudentLogin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        login();
    }
    private void login()
   
    {//判断登录用户
       
        OleDbConnection con = db.con();
        con.Open();
        OleDbCommand cmd = new OleDbCommand("select  * from  Student    where Sname='" + this.TextBox1.Text + "'and Spwd='"+this.TextBox2.Text+"'", con);
        OleDbDataReader sdr = cmd.ExecuteReader();
        if (sdr.Read())
        {
            Session["sname"] = sdr["Sname"].ToString();
            Session["zhuanye"] = sdr["Szhuanye"].ToString();

            Response.Write("<script language='javascript'>alert('登录成功欢迎使用本选课系统');location.href='../student/StudentIndex.aspx'</script>");

        }
        else 
        {

            Response.Write("<script language='javascript'>alert('用户名户密码错误请重新登录');location.href='../student/StudentLogin.aspx'</script>");

        
        }
    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?