| |
|||
Затем определяется элемент управления DropDownList, который будет реализован в виде раскрывающегося списка, содержащего названия всех курсов:
id="ddlCourses" runat="server" DataTextField="CourseFullName" DataValueField="CourseID"> </asp:dropdownlist>
id="butOK" text=" OK " Type="Submit" OnClick="SubmitBtn_Click" runat="server" />
If Len(Session("StudentID")) = 0 Then Response.Redirect("./index.aspx") End If If Not IsPostBack Then Dim DBConn as OleDbConnection Dim DBCommand As OleDbDataAdapter Dim DSPageData as New DataSet IblTitle.Text = "<center>3anncb - " _ & Session("StudentName") & "</center>" DBConn = New OleDbConnection("Provider=sqloledb;" _ & "server=localhost;" _ & "Initial Catalog-INETC9;" & "User Id=sa;" _ & "Password=yourpassword;") DBCommand = New OleDbDataAdapter _ ("Select CourselD, CourseName +'-'"_ & " + CourseDescription as CourseFullName " _ & "From Courses " _ & "Order By CourseName", DBConn) DBCommand.Fill(DSPageData, _ "Courses") ddlCourses.DataSource = _ DSPageData.Tables("Courses").DefaultView ddlCourses.DataBind() End: If End Sub
& Session("StudentName") & "</center>"
& "server=localhost;" _ & "Initial Catalog=INETC9;" & "User Id=sa;" & "Password=yourpassword;")
("Select CourselD, CourseName +'-'"_ & " + CourseDescription as CourseFullName " _ & "From Courses " _ & "Order By CourseName", DBConn) DBCommand.Fill(DSPageData, _ "Courses")
DSPageData.Tables("Courses").DefaultView ddlCourses.DataBindО
Dim DBConn as OleDbConnection Dim DBCommand As OleDbDataAdapter Dim DSPageData as New DataSet Dim DBInsert As New OleDbCommand DBConn = New OleDbConnection("Provider-sqloledb;" _ & "server=localhost;" _ & "Initial Catalog=INETC9;" _ & "User Id=sa;" _ & "Password=yourpassword;") DBCommand = New OleDbDataAdapter _ ("Select StudentCourselD frpm StudentsCourses " _ & "Where StudentID = " & Session("StudentID") _ & " and CourselD = " & ddlCourses.Selectedltem.Value _ , DBConn) DBCommand.Fill(DSPageData, _ "StudentCourse") If DSPageData.Tables("StudentCourse").Rows.Count = 0 Then DBInsert.CommandText = "Insert Into StudentsCourses " _ & "(StudentID, CourselD, DateEnrolled) Values (" _ & Session("StudentID") & ", " _ & ddlCourses.Selectedltem.Value & ", " _ & "GetDateO )" DBInsert.Connection - DBConn DBInsert.Connection.Open DBInsert.ExecuteNonQuery() End If Response.Redirect (". /home_room.aspx") End Sub |
|||