核心代码: 登陆代码: protected void Button1_Click(object sender, EventArgs e) { string name = TextBox1.Text.Trim(); string psw = TextBox2.Text.Trim(); OleDbConnection conn = new OleDbConnection(); conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\专业知识学习\ASP.NET\学生管理系统\students.mdb"; conn.Open(); OleDbCommand cmd = new OleDbCommand(); cmd.Connection = conn; int i = DropDownList1.SelectedIndex; string sql=""; switch(i) { case 0: sql="select * from student"; break; case 1: sql="select * from teacher"; break; case 2: sql="select * from menager"; break; } cmd.CommandType = CommandType.Text; cmd.CommandText = sql; OleDbDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { if (dr[0].ToString() == name && dr[3].ToString()==psw) { this.Session.Add("id", dr[0]); this.Session.Add("username", dr[1]); this.Session.Add("sex", dr[2]); if (i == 0) { this.Session.Add("class", dr[4]); this.Response.Redirect("main.aspx", true); } else if (i == 1) { this.Response.Redirect("teacher.aspx",true); } else { this.Response.Redirect("admin.aspx", true); } dr.Close(); conn.Close(); } } this.Response.Redirect("error.aspx", true); dr.Close(); conn.Close(); } 学生查询课程代码: protected void Page_Load(object sender, EventArgs e) { Label1.Text = (string)this.Session["id"]; if (Label1.Text == "") this.Response.Redirect("login_error.aspx", true); Label2.Text = (string)this.Session["username"]; Label3.Text = (string)this.Session["class"]; AccessDataSource1.SelectCommand = "SELECT st_co.courseid, course.coursename, st_co.grade FROM (st_co INNER JOIN course ON st_co.courseid = course.courseid) WHERE (st_co.grade IS NOT NULL) AND (st_co.studentid = @id)"; AccessDataSource1.SelectParameters.Add("@id", Label1.Text); float sum=0; int count=GridView1.Rows.Count; for (int i = 0; i < cou...