📄 module1.bas
字号:
Attribute VB_Name = "Module1"
Option Explicit
Public rst12 As ADODB.Recordset
Public con1 As ADODB.Connection
Public rst1 As ADODB.Recordset
Public Function exesql(ByVal sql As String) As ADODB.Recordset
'连接数据库子程序
sql = Trim$(sql)
Set con1 = New ADODB.Connection
Dim myStrCnn As String
myStrCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;" & "Data Source=" & App.Path & "\data\db4.mdb;"
con1.Open myStrCnn
Set rst1 = New ADODB.Recordset
rst1.Open sql, con1, adOpenStatic, adLockOptimistic
'If rst1.RecordCount = 0 Then
'MsgBox "没有找到您需要的数据记录", vbOKOnly
'End If
Set exesql = rst1
'rst1.Open sql, con1, adOpenStatic, adLockOptimistic
Set con1 = Nothing
Set rst1 = Nothing
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -