📄 moddsn.bas
字号:
Attribute VB_Name = "modDSN"
Private Const ODBC_ADD_SYS_DSN = 4 ' Add data source
Private Const ODBC_CONFIG_DSN = 2 ' Configure (edit) data Source
Private Const ODBC_REMOVE_DSN = 3 ' Remove data source
Private Const vbAPINull As Long = vbNull ' NULL Pointer
'Function Declare
Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" _
(ByVal hwndParent As Long, ByVal fRequest As Long, _
ByVal lpszDriver As String, ByVal lpszAttributes As String) _
As Long
Public Sub createDSN()
'Creating the DSN
#If Win32 Then
Dim intRet As Long
#Else
Dim intRet As Integer
#End If
Dim strDriver As String
Dim strAttributes As String
strDriver = "Microsoft Access Driver (*.mdb)"
strAttributes = strAttributes & "DESCRIPTION=" & "VT Marketing DSN " & Chr$(0)
strAttributes = strAttributes & "DSN=" & "VT" & Chr$(0)
strAttributes = strAttributes & "PWD=" & "jaypee" & Chr$(0)
strAttributes = strAttributes & "UID=" & "admin" & Chr$(0)
strAttributes = strAttributes & "DBQ=" & DBPath & Chr$(0)
intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_SYS_DSN, _
strDriver, strAttributes)
' DSN created
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -