private void StudentList_SelectedIndexChanged(object sender, EventArgs e) { textBox2.Text = ""; textBox1.Text = ""; string studentId = MyTool.getStudentIdByStudentName(StudentList.Text); string sqlStr = "select Student_course.ID as 记录ID,Student_name as 学生姓名,Class_name as 班级" + " ,Course_name as 课程, Student_course.Score as 成绩 from Student,Course,Student_course,Class" + " where Student.Student_id=Student_course.Student_id and Course.Course_id=Student_course.Course_id" + " and Class.Class_id =Student.Class_id and Student.Student_id ='" + studentId + "'"; //填充数据表 MyTool.queryDataToGrid(sqlStr, dataGridView1); }
private void StudentList_SelectedIndexChanged(object sender, EventArgs e) { //string studentId = MyTool.getStudentIdByStudentName(StudentList.Text); //string sqlStr = "select Student_course.ID as 记录ID,Student_name as 学生姓名,Class_name as 班级" + // " ,Course_name as 课程,Course.Credit as 学分 from Student,Course,Student_course,Class" + // " where Student.Student_id=Student_course.Student_id and Course.Course_id=Student_course.Course_id" + // " and Class.Class_id =Student.Class_id and Student.Student_id ='" + studentId + "'"; ////填充数据表 //MyTool.queryDataToGrid(sqlStr, dataGridView1); ////填充学生下拉框 //sqlStr = "select Student_name from Student"; //MyTool.queryDataToComno(sqlStr, "Student_name", StudentList); //sqlStr = "select Student_id from Student where Student_name='" + StudentList.Text + "'"; //SqlConnection sqlconncetion1 = new SqlConnection(MyTool.connStr); //sqlconncetion1.Open(); //SqlCommand sqlcommand1 = new SqlCommand(sqlStr, sqlconncetion1); //string studentId = sqlcommand1.ExecuteScalar().ToString(); //sqlconncetion1.Close(); //sqlStr = "select Student_course.ID as 记录ID,Student_name as 学生姓名,Class_name as 班级" + // " ,Course_name as 课程,Course.Credit as 学分 from Student,Course,Student_course,Class" + // " where Student.Student_id=Student_course.Student_id and Course.Course_id=Student_course.Course_id" + // " and Class.Class_id =Student.Class_id and Student.Student_id ='" + studentId + "'"; ////填充数据表 //MyTool.queryDataToGrid(sqlStr, dataGridView1); ////填充学生下拉框 //sqlStr = "select Student_name from Student"; //MyTool.queryDataToComno(sqlStr, "Student_name", StudentList); string studentId = MyTool.getStudentIdByStudentName(StudentList.Text); string sqlStr = "select Student_course.ID as 记录ID,Student_name as 学生姓名,Class_name as 班级" + " ,Course_name as 课程, Student_course.Score as 成绩 from Student,Course,Student_course,Class" + " where Student.Student_id=Student_course.Student_id and Course.Course_id=Student_course.Course_id" + " and Class.Class_id =Student.Class_id and Student.Student_id ='" + studentId + "'"; //填充数据表 MyTool.queryDataToGrid(sqlStr, dataGridView1); }