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

📄 frmselectdotest.frm

📁 自测考试系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form selectdotest 
   Caption         =   "选择本次考试"
   ClientHeight    =   3090
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3090
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.ComboBox cmbTest 
      Height          =   300
      ItemData        =   "frmselectdotest.frx":0000
      Left            =   1485
      List            =   "frmselectdotest.frx":0002
      Style           =   2  'Dropdown List
      TabIndex        =   2
      Top             =   840
      Width           =   2385
   End
   Begin VB.CommandButton cmdExit 
      Cancel          =   -1  'True
      Caption         =   "退出"
      Height          =   315
      Left            =   2370
      TabIndex        =   1
      Top             =   1515
      Width           =   795
   End
   Begin VB.CommandButton cmdOk 
      Caption         =   "确定"
      Default         =   -1  'True
      Height          =   315
      Left            =   1440
      TabIndex        =   0
      Top             =   1515
      Width           =   795
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "试卷名称"
      Height          =   180
      Left            =   720
      TabIndex        =   3
      Top             =   900
      Width           =   720
   End
End
Attribute VB_Name = "selectdotest"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim objcn As New Connection, objold As Recordset

Private Sub cmdexit_Click()
    Unload Me
End Sub

Private Sub cmdok_Click()
    Dim strsql$
    '将选择的考试题数据表数据复制道ThisTest数据表中
    With objcn
        strsql = "Drop Table ThisTest"
        .Execute strsql
        strsql = "select 编号,题型,分数 into ThisTest From " & cmbTest
        .Execute strsql
    End With
    MsgBox "试题选择成功!", vbInformation, Me.Caption
End Sub

Private Sub Form_Load()
    With objcn                                 '建立数据库联接
        .Provider = "SQLOLEDB"
        .ConnectionString = "User ID=sa;Data Source=(local);" & _
                            "Initial Catalog=自测考试"
        .Open
    End With
    '访问数据库获得历届试题数据
    Set objold = New Recordset                '实例化对象
    With objold
        Set .ActiveConnection = objcn           '建立数据库连接
        .CursorLocation = adUseClient           '指定使用客户端游标
        .CursorType = adOpenStatic              '指定使用静态游标
        .Open "SELECT * FROM 历届考题"          '获取历届试题数据
        Set .ActiveConnection = Nothing         '断开数据库连接
        If .RecordCount > 0 Then
            .MoveFirst
            While Not .EOF
                cmbTest.AddItem .Fields("表名")
                .MoveNext
            Wend
        End If
        cmbTest.ListIndex = 0
    End With
End Sub


Private Sub Form_Unload(Cancel As Integer)
    objcn.Close                      '关闭数据库连接
    Set objold = Nothing
    Set objcn = Nothing
End Sub


⌨️ 快捷键说明

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