View Single Post
  #2 (permalink)  
Old May 5th, 2006, 02:20 PM
jmjyiannis jmjyiannis is offline
Registered User
Join Date: Jun 2004
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts


Just in case that anyone is in the same position in which I was..... the Solution comes from a multiple insert-select subquery:

   cmdSelect = New SqlCommand("insert into attendedLessons (LessonID,StudentID,TeacherID,CourseID)
(select distinct lessonID, studentid, PersonID, courseid from Lesson, student, Personnel where Courseid='" & Request.QueryString("CourseID") & "' and studentID='" & ID & "' and PersonID='" & InstructorID & "')", conn)

The result will be to insert as many records the table "lesson" has with the courseID foreignKEY =Request.QueryString("CourseID") with the ID of the student and the ID of the teacher.

Reply With Quote