⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 查询课程.aspx.vb

📁 本套软件适用于各大高校、培训机构等单位的教学管理软件。
💻 VB
字号:
Imports System.Data
Imports System.Data.SqlClient
Partial Class CourseUpdata_DB

    Inherits System.Web.UI.Page
    Public a As Integer




    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' Dim strsql1 As String
       
        If (DropDownList1.SelectedValue = "1") Then

            Dim coon As New SqlConnection("Server=localhost;Database=选修课管理系统;Uid=sa;Pwd=;")
            Dim cmd As New SqlCommand("select * from 课程表 where 课程号='" & (DropDownList2.SelectedItem.Text) & "' ", coon)
            coon.Open()
            Dim dr As SqlDataReader = cmd.ExecuteReader()
            GridView1.DataSource = dr
            GridView1.DataBind()
            coon.Close()

        ElseIf (DropDownList1.SelectedValue = "2") Then

            Dim coon As New SqlConnection("Server=localhost;Database=选修课管理系统;Uid=sa;Pwd=;")
            Dim cmd As New SqlCommand("select * from 课程表 where 课程名='" & (DropDownList2.SelectedItem.Text) & "' ", coon)
            coon.Open()
            Dim dr As SqlDataReader = cmd.ExecuteReader()
            GridView1.DataSource = dr
            GridView1.DataBind()
            coon.Close()
        ElseIf (DropDownList1.SelectedValue = "3") Then

            Dim coon As New SqlConnection("Server=localhost;Database=选修课管理系统;Uid=sa;Pwd=;")
            Dim cmd As New SqlCommand("select * from 课程表 where 开课学期='" & (DropDownList2.SelectedItem.Text) & "' ", coon)
            coon.Open()
            Dim dr As SqlDataReader = cmd.ExecuteReader()
            GridView1.DataSource = dr
            GridView1.DataBind()
            coon.Close()
        ElseIf (DropDownList1.SelectedValue = "4") Then

            Dim coon As New SqlConnection("Server=localhost;Database=选修课管理系统;Uid=sa;Pwd=;")
            Dim cmd As New SqlCommand("select 课程名, 学分, 学时 ,上课时间 ,上课地点 ,开课学期 ,已选人数 ,限选人数  , 老师表.姓名  from 课程表 join 老师表 on 老师表.教师编号=课程表.教师编号  where 老师表.姓名='" & (DropDownList2.SelectedItem.Text) & "'", coon)
            coon.Open()
            Dim dr As SqlDataReader = cmd.ExecuteReader()
            GridView1.DataSource = dr
            GridView1.DataBind()
            coon.Close()

        End If






    End Sub

    Protected Sub DropDownList1_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.Init
        Dim strsql As String
        Dim coon As New SqlConnection("Server=localhost;Database=选修课管理系统;Uid=sa;Pwd=;")
        strsql = "select 课程号 from 课程表"
        DropDownList2.DataTextField = "课程号"
        DropDownList2.DataValueField = "课程号"
        coon.Open()
        Dim cmd1 As New SqlCommand(strsql, coon)
        Dim dr1 As SqlDataReader = cmd1.ExecuteReader()
        DropDownList2.DataSource = dr1
        DropDownList2.DataBind()
        coon.Close()


    End Sub


    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
        Dim strsql As String
        Dim coon As New SqlConnection("Server=localhost;Database=选修课管理系统;Uid=sa;Pwd=;")
        If (DropDownList1.SelectedItem.Text) = "课程名" Then
            strsql = "select 课程名 from 课程表"
            DropDownList2.DataTextField = "课程名"
            DropDownList2.DataValueField = "课程名"
            a = 1

        ElseIf (DropDownList1.SelectedItem.Text) = "课程号" Then
            strsql = "select 课程号 from 课程表"
            DropDownList2.DataTextField = "课程号"
            DropDownList2.DataValueField = "课程号"
            a = 2


        ElseIf (DropDownList1.SelectedItem.Text) = "开课学期" Then
            strsql = "select 开课学期 from 课程表"
            DropDownList2.DataTextField = "开课学期"
            DropDownList2.DataValueField = "开课学期"
            a = 3

        Else : strsql = "select 姓名 from 老师表"
            DropDownList2.DataTextField = "姓名"
            DropDownList2.DataValueField = "姓名"
            a = 4

        End If
        coon.Open()
        Dim cmd1 As New SqlCommand(strsql, coon)
        Dim dr1 As SqlDataReader = cmd1.ExecuteReader()
        DropDownList2.DataSource = dr1

        DropDownList2.DataBind()
        coon.Close()

    End Sub


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


    End Sub




End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -