?? 手動配置odbc.frm
字號:
VERSION 5.00
Begin VB.Form 手動配置ODBC
BackColor = &H8000000A&
Caption = "手動配置ODBC"
ClientHeight = 1665
ClientLeft = 60
ClientTop = 345
ClientWidth = 6165
LinkTopic = "Form1"
ScaleHeight = 1665
ScaleWidth = 6165
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
BackColor = &H80000009&
Caption = "確 認"
Enabled = 0 'False
Height = 285
Left = 5010
TabIndex = 7
Top = 1290
Width = 840
End
Begin VB.TextBox Text4
Alignment = 1 'Right Justify
BackColor = &H80000001&
DataField = "最后學歷"
DataSource = "Adodc1"
Height = 270
Left = 4170
TabIndex = 5
Text = "Text4"
Top = 810
Width = 1860
End
Begin VB.TextBox Text3
Alignment = 1 'Right Justify
BackColor = &H80000001&
DataField = "性別"
DataSource = "Adodc1"
Height = 270
Left = 1200
TabIndex = 4
Text = "Text3"
Top = 810
Width = 1935
End
Begin VB.TextBox Text2
Alignment = 1 'Right Justify
BackColor = &H80000001&
DataField = "出生日期"
DataSource = "Adodc1"
Height = 270
Left = 4170
TabIndex = 2
Text = "Text2"
Top = 150
Width = 1890
End
Begin VB.TextBox Text1
Alignment = 1 'Right Justify
DataField = "姓名"
DataSource = "Adodc1"
Height = 285
Left = 1440
TabIndex = 0
Text = "Text1"
Top = 180
Width = 1050
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "數據庫名稱:"
Height = 180
Left = 240
TabIndex = 8
Top = 210
Width = 1080
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "服務器名:"
Height = 180
Left = 240
TabIndex = 6
Top = 810
Width = 900
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "用戶名:"
Height = 180
Left = 3390
TabIndex = 3
Top = 840
Width = 720
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "數據驅動程序:"
Height = 180
Left = 2850
TabIndex = 1
Top = 210
Width = 1260
End
End
Attribute VB_Name = "手動配置ODBC"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpData As Any, ByVal cbData As Long) As Long
Const REG_SZ = 1
Const HKEY_LOCAL_MACHINE = &H80000002
Dim A1 As String, A2 As String, A3 As String, A4 As String
Private Sub Form_Load()
Text1 = "": Text2 = "": Text3 = "": Text4 = ""
Text1.Enabled = True
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
A1 = Text1
Text2.Enabled = True
Text2.SetFocus
Text2.BackColor = &H80000005
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
A2 = Text2
Text3.Enabled = True
Text3.SetFocus
Text3.BackColor = &H80000005
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text2.Enabled = True
A3 = Text3
Text4.Enabled = True
Text4.SetFocus
Text4.BackColor = &H80000005
End If
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
A4 = Text4
Command1.Enabled = True
Command1.SetFocus
End If
End Sub
Private Sub Command1_Click()
Dim hKey As Long
RegOpenKey HKEY_LOCAL_MACHINE, "SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources", hKey
RegSetValueEx hKey, A1, 0&, REG_SZ, A2, Len(A2)
RegCloseKey hKey
RegCreateKey HKEY_LOCAL_MACHINE, "SOFTWARE\ODBC\ODBC.INI\" & A1, hKey
RegSetValueEx hKey, "Database", 0&, REG_SZ, A1, 2 * Len(A1)
RegSetValueEx hKey, "Driver", 0&, REG_SZ, "C:\WINDOWS\SYSTEM\SQLSRV32.DLL", Len("C:\WINDOWS\System\SQLSRV32.DLL")
RegSetValueEx hKey, "LastUser", 0&, REG_SZ, A4, Len(A4)
RegSetValueEx hKey, "Server", 0&, REG_SZ, A3, Len(A3)
RegSetValueEx hKey, "Trusted_Connection", 0&, REG_SZ, "Yes", Len("Yes")
RegCloseKey hKey
Unload Me
數據庫操作.Show
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -