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

📄 ok查询学生.aspx.vb

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

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim coon As New SqlConnection("Server=localhost;Database=选修课管理系统;Uid=sa;Pwd=;")
        Dim strsql As String
        coon.Open()

        'If DropDownList1.SelectedItem.Value = "学号" Then
        '    strsql = "select 学号,姓名,性别,专业 from 学生表 where 学号='" & Trim(DropDownList2.SelectedItem.Text) & "'"
        'ElseIf DropDownList1.SelectedItem.Value = "姓名" Then
        '    : strsql = "select 学号,姓名,性别,专业 from 学生表 where 姓名='" & Trim(DropDownList2.SelectedItem.Text & "'")
        'Else : strsql = "select 学号,姓名,性别,专业 from 学生表 where 专业='" & Trim(DropDownList2.SelectedItem.Text & "'")
        'End If


        strsql = "select 学号,姓名,性别,专业 from 学生表 where 学号='" & Trim(DropDownList2.SelectedItem.Text) & "'"
        Dim cmd As New SqlCommand(strsql, coon)
        Dim dr As SqlDataReader = cmd.ExecuteReader()
        DetailsView1.DataSource = dr
        DetailsView1.DataBind()
        coon.Close()
        'da = New Data.SqlClient.SqlDataAdapter(conStr, con) 
        'da.Fill(ds, "port") 
    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 = "学号"

    '    ElseIf (DropDownList1.SelectedItem.Text) = "姓名" Then
    '        strsql = "select 姓名 from 学生表"
    '        DropDownList2.DataTextField = "姓名"
    '        DropDownList2.DataValueField = "姓名"

    '    Else : strsql = "select 专业 from 学生表"
    '        DropDownList2.DataTextField = "专业"
    '        DropDownList2.DataValueField = "专业"
    '    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 DropDownList2_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList2.Init
        Dim coon As New SqlConnection("Server=localhost;Database=选修课管理系统;Uid=sa;Pwd=;")
        Dim strsql As String

        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



End Class

⌨️ 快捷键说明

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