📄 frmselectdotest.frm
字号:
VERSION 5.00
Begin VB.Form SelectDoTest
BorderStyle = 1 'Fixed Single
Caption = "选择本次考题"
ClientHeight = 4170
ClientLeft = 45
ClientTop = 330
ClientWidth = 7065
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 4170
ScaleWidth = 7065
Begin VB.CommandButton cmdOk
Caption = "确定"
Default = -1 'True
Height = 315
Left = 1440
TabIndex = 3
Top = 1110
Width = 795
End
Begin VB.CommandButton cmdExit
Cancel = -1 'True
Caption = "退出"
Height = 315
Left = 2370
TabIndex = 2
Top = 1110
Width = 795
End
Begin VB.ComboBox cmbTest
Height = 300
Left = 1492
Style = 2 'Dropdown List
TabIndex = 1
Top = 435
Width = 2385
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "试卷名称"
Height = 180
Left = 727
TabIndex = 0
Top = 495
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;PWD=123;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 + -