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

📄 frminquirestinfo.vb

📁 这是一个教务信息管理系统!
💻 VB
字号:
Imports System.Data
'引入数据库操作类命名空间
Imports System.Data.OleDb
'引入ADO.NET操作命名空间
Public Class FrmInquirestInfo
    Inherits System.Windows.Forms.Form
    Public ADOcmd As OleDbDataAdapter
    Public ds As DataSet = New DataSet()
    '建立DataSet对象 
    Public mytable As Data.DataTable
    '建立表单对象
    Public myrow As Data.DataRow
    '建立数据行对象
    Public rownumber As Integer
    '定义一个整型变量来存放当前行数
    Public SearchSQL As String
    Public cmd As OleDbCommandBuilder
#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写处置以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意:以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents DgstInfo As System.Windows.Forms.DataGrid
    Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
    Friend WithEvents BtExit As System.Windows.Forms.Button
    Friend WithEvents BtInquire As System.Windows.Forms.Button
    Friend WithEvents TxtSearchValue As System.Windows.Forms.TextBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents ComboSearchtype As System.Windows.Forms.ComboBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.DgstInfo = New System.Windows.Forms.DataGrid()
        Me.GroupBox2 = New System.Windows.Forms.GroupBox()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.TxtSearchValue = New System.Windows.Forms.TextBox()
        Me.ComboSearchtype = New System.Windows.Forms.ComboBox()
        Me.BtExit = New System.Windows.Forms.Button()
        Me.BtInquire = New System.Windows.Forms.Button()
        CType(Me.DgstInfo, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.GroupBox2.SuspendLayout()
        Me.SuspendLayout()
        '
        'DgstInfo
        '
        Me.DgstInfo.DataMember = ""
        Me.DgstInfo.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.DgstInfo.Location = New System.Drawing.Point(8, 104)
        Me.DgstInfo.Name = "DgstInfo"
        Me.DgstInfo.Size = New System.Drawing.Size(448, 208)
        Me.DgstInfo.TabIndex = 0
        '
        'GroupBox2
        '
        Me.GroupBox2.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label2, Me.Label1, Me.TxtSearchValue, Me.ComboSearchtype, Me.BtExit, Me.BtInquire})
        Me.GroupBox2.Font = New System.Drawing.Font("宋体", 10.5!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.GroupBox2.Location = New System.Drawing.Point(8, 8)
        Me.GroupBox2.Name = "GroupBox2"
        Me.GroupBox2.Size = New System.Drawing.Size(448, 88)
        Me.GroupBox2.TabIndex = 7
        Me.GroupBox2.TabStop = False
        Me.GroupBox2.Text = "查询学籍信息"
        '
        'Label2
        '
        Me.Label2.Font = New System.Drawing.Font("宋体", 10.5!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.Label2.Location = New System.Drawing.Point(144, 17)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(80, 24)
        Me.Label2.TabIndex = 12
        Me.Label2.Text = "查询条件"
        '
        'Label1
        '
        Me.Label1.Font = New System.Drawing.Font("宋体", 10.5!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.Label1.Location = New System.Drawing.Point(24, 17)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(80, 24)
        Me.Label1.TabIndex = 11
        Me.Label1.Text = "查询方式"
        '
        'TxtSearchValue
        '
        Me.TxtSearchValue.Font = New System.Drawing.Font("宋体", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.TxtSearchValue.Location = New System.Drawing.Point(136, 48)
        Me.TxtSearchValue.Name = "TxtSearchValue"
        Me.TxtSearchValue.Size = New System.Drawing.Size(80, 23)
        Me.TxtSearchValue.TabIndex = 10
        Me.TxtSearchValue.Text = ""
        '
        'ComboSearchtype
        '
        Me.ComboSearchtype.Font = New System.Drawing.Font("宋体", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.ComboSearchtype.ItemHeight = 12
        Me.ComboSearchtype.Items.AddRange(New Object() {"学号", "姓名", "性别", "出生日期", "班号", "联系电话", "入校日期", "家庭住址"})
        Me.ComboSearchtype.Location = New System.Drawing.Point(24, 48)
        Me.ComboSearchtype.Name = "ComboSearchtype"
        Me.ComboSearchtype.Size = New System.Drawing.Size(80, 20)
        Me.ComboSearchtype.TabIndex = 9
        Me.ComboSearchtype.Text = "学号"
        '
        'BtExit
        '
        Me.BtExit.Font = New System.Drawing.Font("宋体", 10.5!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.BtExit.Location = New System.Drawing.Point(336, 39)
        Me.BtExit.Name = "BtExit"
        Me.BtExit.Size = New System.Drawing.Size(96, 32)
        Me.BtExit.TabIndex = 8
        Me.BtExit.Text = "退出查询"
        '
        'BtInquire
        '
        Me.BtInquire.Font = New System.Drawing.Font("宋体", 10.5!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.BtInquire.Location = New System.Drawing.Point(232, 39)
        Me.BtInquire.Name = "BtInquire"
        Me.BtInquire.Size = New System.Drawing.Size(80, 32)
        Me.BtInquire.TabIndex = 7
        Me.BtInquire.Text = "查询"
        '
        'FrmInquirestInfo
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(464, 317)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.GroupBox2, Me.DgstInfo})
        Me.Name = "FrmInquirestInfo"
        Me.Text = "查询学籍信息"
        CType(Me.DgstInfo, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupBox2.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    
   
  
   
    
    Private Sub BtExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtExit.Click
        Me.Dispose()
    End Sub

    Private Sub BtInquire_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtInquire.Click
        Try
            SearchSQL = "SELECT * FROM student_Info WHERE (" & ComboSearchtype.Text & "= '" & TxtSearchValue.Text & "')"
            '建立查询
            ExecuteSQL(SearchSQL, "student_Info")
            DgstInfo.DataSource = ds.Tables.Item(0).DefaultView
            '绑定数据
        Catch
            MsgBox("不存在该记录!", vbOKOnly + vbExclamation, "警告")
        End Try
    End Sub
   
    Public Function ExecuteSQL(ByVal SQL As String, ByVal table As String)
        Try


            '建立ADODataSetCommand对象
            '数据库查询函数
            ADOcmd = New OleDbDataAdapter(SQL, "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\冯军\student.mdb")
            '建立ADODataSetCommand对象
            ADOcmd.Fill(ds, table) '取得表单
            mytable = ds.Tables.Item(0) '取得名为table的表
            rownumber = 0 '设置为第一行
            myrow = mytable.Rows.Item(rownumber)
            '取得第一行数据
        Catch
            MsgBox(Err.Description)
        End Try
    End Function
End Class

⌨️ 快捷键说明

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