📄 module1.bas
字号:
Attribute VB_Name = "Module1"
Option Explicit
Const AutoLogin As Boolean = False
Const MAX_COMPUTERNAME As Integer = 20
Public strPath As String
Public Cn As New ADODB.Connection
Public SvrName As String
Public CurUser As String
Public CurPwd As String
Public Logined As Boolean
'***********主数据库信息
Public Const gstr_DbMain = "qfMaster"
Public Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Sub Main()
On Error GoTo Er
strPath = IIf(Right(App.Path, 1) = "\", App.Path, App.Path & "\")
Cn.CursorLocation = adUseClient
Cn.ConnectionTimeout = 20
Cn.CommandTimeout = 0
SvrName = String(MAX_COMPUTERNAME + 1, " ")
Call GetComputerName(SvrName, MAX_COMPUTERNAME + 1)
SvrName = Trim(SvrName)
Load Frm_Login
If Not AutoLogin Then
Frm_Login.Show 1
Else
Call Frm_Login.Login
End If
If Logined Then Frm_Main.Show 1
Exit Sub
Er:
MsgBox "错误:" & Err.Number & " 来自:" & Err.Source & vbCrLf & " 详细:" & Err.Description, vbExclamation, "错误:" & Err.Number
End Sub
'生成连接串
Public Function CreateCnStr(Uid As String, Pwd As String, Server As String, dbname As String) As String
CreateCnStr = "Provider=SQLOLEDB;User ID=" & Uid & ";PassWord=" & Pwd & ";Initial Catalog=" & dbname & ";Data Source=" & Server
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -