📄 moduledatabase.bas
字号:
Attribute VB_Name = "Module1"
Option Explicit
Public strUserName As String '用户名称
Public iflag As Integer '是否连接成功标志
Public ichangeFlag As Integer '修改标志
Public strPublicSQL As String '传递SQL字符串
Public Function getRS(ByVal sql As String, ByVal databasename As String) _
As ADODB.Recordset
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strConnection As String
Dim strArray() As String
Set con = New ADODB.Connection '创建连接
Set rs = New ADODB.Recordset '创建记录集
On Error GoTo getRS_Error
strConnection = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=shujuku;Data Source=(local)"
strArray = Split(sql)
con.Open strConnection '打开连接
rs.Open Trim$(sql), con, adOpenKeyset, adLockOptimistic
Set getRS = rs '返回记录集
iflag = 1
getRS_Exit:
Set rs = Nothing
Set con = Nothing
Exit Function
getRS_Error:
MsgBox "查询错误:" & Err.Description
iflag = 2
Resume getRS_Exit
End Function
Public Sub TransactSQL(ByVal sql As String, ByVal databasename As String)
Dim con As ADODB.Connection
Dim strConnection As String
Dim strArray() As String
Set con = New ADODB.Connection '创建连接
On Error GoTo TransactSQL_Error
strConnection = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=shujuku;Data Source=(local)"
strArray = Split(sql)
con.Open strConnection '打开连接
con.Execute sql '执行命令
iflag = 1
TransactSQL_Exit:
Set con = Nothing
Exit Sub
TransactSQL_Error:
MsgBox "查询错误:" & Err.Description
iflag = 2
Resume TransactSQL_Exit
End Sub
Public Sub TabToEnter(Key As Integer)
If Key = 13 Then '判断是否为回车键
SendKeys "{TAB}" '转换为Tab键
End If
End Sub
Sub Main()
Dim fLogin As New frmLogin
fLogin.Show '显示窗体
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -