public void PostOldStudent(Student student) { SystemContext context = HttpContext.RequestServices.GetService(typeof(Exam_Management_System.Models.SystemContext)) as SystemContext; int academic = context.GetAcademicSecond().Id; int student_id = context.GetStudentId(student.Rollno, academic); int mark = context.GetMark(student_id); using (MySqlConnection conn = context.GetConnection()) { conn.Open(); string sql1 = $"Insert Into old_student (student_year_id,address,phone,father_phone,mother_phone,email,academic_id,major_id,student_id,mark) Values ('{student.Year_id}','{student.Address}','{student.Phone}','{student.Father_phone}','{student.Mother_phone}','{student.Email}','{student.Academic_id}','{student.Major_id}','{student_id}','{mark}')"; using (MySqlCommand command1 = new MySqlCommand(sql1, conn)) { command1.ExecuteNonQuery(); } } // return Redirect("/Student/AddOldStudent"); }