周路db_studentadd.aspx.vb

来自「本套软件适用于各大高校、培训机构等单位的教学管理软件。」· VB 代码 · 共 61 行

VB
61
字号
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.OleDb
Imports System.Drawing

Partial Class _Default
    Inherits System.Web.UI.Page
    Public ds As DataSet
    Public index As Integer
    Public sqlstr As String
    Public DR As DataRow
    Public ConnectStr As String
    Public DataAdapter As OleDbDataAdapter
    Public DataConnection As OleDbConnection
    Public DataSet As DataSet
    Public 学号 As String
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim strsql As String
        Dim conn As New SqlConnection("Server=localhost;Database=选修课管理系统;Uid=sa;Pwd=;")
        strsql = "SELECT * FROM 选修表 WHERE 学号 = '" & TextBox1.Text & "'"
        Dim cmd As New SqlCommand(strsql, conn)
        conn.Open()
        Dim dr As SqlDataReader = cmd.ExecuteReader()
        GridView1.DataSource = dr
        GridView1.DataBind()
        conn.Close()
    End Sub
    Public Function GetDataFromDB(ByVal sqlstr As String) As DataSet
        Try
            DataConnection = New OleDbConnection()
            DataConnection.ConnectionString = ConnectStr
            DataAdapter = New OleDbDataAdapter(sqlstr, DataConnection)
            DataSet = New DataSet()
            DataSet.Clear()
            DataAdapter.Fill(DataSet)
            DataConnection.Close()
            If Not DataSet Is Nothing Then
                Return DataSet

            End If
        Catch ex As Exception
        End Try
    End Function
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        学号 = "200508213"
        Dim strsql As String
        Dim conn As New SqlConnection("Server=localhost;Database=选修课管理系统;Uid=sa;Pwd=;")
        strsql = "SELECT * FROM 选修表 WHERE 学号 = '" & 学号 & "'"
        Dim cmd As New SqlCommand(strsql, conn)
        conn.Open()
        Dim dr As SqlDataReader = cmd.ExecuteReader()
        GridView1.DataSource = dr
        GridView1.DataBind()
        conn.Close()
    End Sub



    
End Class

⌨️ 快捷键说明

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