0

私はASPページを書いています:学生がログインする->学生がウェルカムページに到達し、登録されたコースを表示するためのリンクが表示されます->リンクされたページにコース情報、説明などが表示されます.

3 つのテーブルを持つ MS Access データベースがあります:学生および学生がサインアップしたコースを表すコース)。

登録されているコースとコース情報を表示する必要があるため、登録済みコースを示す EnrolledCourses からのデータと、コースの詳細を示す Courses からのデータを表示する必要があります。その情報を引き出すためのクエリが何であるかを理解するのに苦労しています。これは私がこれまでに思いついたものです:

{               
        //Give the command SQL to execute   
    comm.CommandText = "SELECT Courses.Id, Courses.CourseSubject, Courses.CourseName, Courses.CourseNumber, Courses.CourseDescription FROM Courses, StudentToCourse, Students WHERE Courses.Id = StudentToCourse.Courseid AND Session["id"] = StudentToCourse.Studentid";

}

これが正しい軌道に乗っているかどうか疑問に思っていますか?次のコンパイル エラーが発生し続けます: Compiler Error Message: CS1002: ; 期待される

4

1 に答える 1

0

これを試すことができますか:

    comm.CommandText = "SELECT Courses.Id, Courses.CourseSubject, Courses.CourseName, Courses.CourseNumber, Courses.CourseDescription
FROM Courses, StudentToCourse, Students WHERE Courses.Id = StudentToCourse.Courseid AND StudentToCourse.Studentid = " + Session["id"];

しかし、脆弱性があります。次のようなパラメーターを追加する必要があります。

comm.CommandText = "... StudentToCourse.Studentid=@studentID";
comm.Parameters.AddWithValue("@studentID", Session["id"]);

そのほうが安全です。

于 2013-05-16T02:19:33.947 に答える