📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "使用Recordset对象"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton CmdExit
Caption = "退 出"
Height = 495
Left = 960
TabIndex = 1
Top = 1560
Width = 2295
End
Begin VB.CommandButton CmdExecute
Caption = "实例化Recordset对象"
Height = 495
Left = 960
TabIndex = 0
Top = 480
Width = 2295
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim connstr As String
Dim sql As String
'单击实例化Recordset对象按钮后的执行代码
Private Sub CmdExecute_Click()
connstr = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=db_student;Data Source = mynetserver"
conn.ConnectionString = connstr
conn.Open connstr
sql = "Select * from T_STUDENT"
rs.CursorLocation = adUseClient
rs.Open sql, conn, adOpenKeyset, adLockPessimistic
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
MsgBox "成功完成Recordset对象的操作流程", , "成功提示"
End Sub
'单击退出按钮后的执行代码
Private Sub CmdExit_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -